Update 'DispatchSourceExamples' sample (#311)
* added new project * added assets * deleted old project + updated docs
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DispatchSourceExamples", "DispatchSourceExamples\DispatchSourceExamples.csproj", "{A46BC836-0B98-4EB2-AF31-BEEBE5BEFB20}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DispatchSourceExamples", "DispatchSourceExamples\DispatchSourceExamples.csproj", "{339EADEE-24FD-4431-9198-9CED1B8677E6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -13,17 +13,17 @@ Global
|
|||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A46BC836-0B98-4EB2-AF31-BEEBE5BEFB20}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
|
||||
{A46BC836-0B98-4EB2-AF31-BEEBE5BEFB20}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
|
||||
{A46BC836-0B98-4EB2-AF31-BEEBE5BEFB20}.Debug|iPhone.ActiveCfg = Debug|iPhone
|
||||
{A46BC836-0B98-4EB2-AF31-BEEBE5BEFB20}.Debug|iPhone.Build.0 = Debug|iPhone
|
||||
{A46BC836-0B98-4EB2-AF31-BEEBE5BEFB20}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
|
||||
{A46BC836-0B98-4EB2-AF31-BEEBE5BEFB20}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
|
||||
{A46BC836-0B98-4EB2-AF31-BEEBE5BEFB20}.Release|Any CPU.ActiveCfg = Release|iPhone
|
||||
{A46BC836-0B98-4EB2-AF31-BEEBE5BEFB20}.Release|Any CPU.Build.0 = Release|iPhone
|
||||
{A46BC836-0B98-4EB2-AF31-BEEBE5BEFB20}.Release|iPhone.ActiveCfg = Release|iPhone
|
||||
{A46BC836-0B98-4EB2-AF31-BEEBE5BEFB20}.Release|iPhone.Build.0 = Release|iPhone
|
||||
{A46BC836-0B98-4EB2-AF31-BEEBE5BEFB20}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
|
||||
{A46BC836-0B98-4EB2-AF31-BEEBE5BEFB20}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
|
||||
{339EADEE-24FD-4431-9198-9CED1B8677E6}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
|
||||
{339EADEE-24FD-4431-9198-9CED1B8677E6}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
|
||||
{339EADEE-24FD-4431-9198-9CED1B8677E6}.Release|iPhone.ActiveCfg = Release|iPhone
|
||||
{339EADEE-24FD-4431-9198-9CED1B8677E6}.Release|iPhone.Build.0 = Release|iPhone
|
||||
{339EADEE-24FD-4431-9198-9CED1B8677E6}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
|
||||
{339EADEE-24FD-4431-9198-9CED1B8677E6}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
|
||||
{339EADEE-24FD-4431-9198-9CED1B8677E6}.Debug|iPhone.ActiveCfg = Debug|iPhone
|
||||
{339EADEE-24FD-4431-9198-9CED1B8677E6}.Debug|iPhone.Build.0 = Debug|iPhone
|
||||
{339EADEE-24FD-4431-9198-9CED1B8677E6}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
|
||||
{339EADEE-24FD-4431-9198-9CED1B8677E6}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
|
||||
{339EADEE-24FD-4431-9198-9CED1B8677E6}.Release|Any CPU.ActiveCfg = Release|iPhone
|
||||
{339EADEE-24FD-4431-9198-9CED1B8677E6}.Release|Any CPU.Build.0 = Release|iPhone
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -1,16 +1,21 @@
|
|||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
namespace DispatchSourceExamples {
|
||||
[Register ("AppDelegate")]
|
||||
public class AppDelegate : UIApplicationDelegate {
|
||||
public override UIWindow Window { get; set; }
|
||||
|
||||
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace DispatchSourceExamples
|
||||
{
|
||||
// The UIApplicationDelegate for the application. This class is responsible for launching the
|
||||
// User Interface of the application, as well as listening (and optionally responding) to application events from iOS.
|
||||
[Register("AppDelegate")]
|
||||
public class AppDelegate : UIApplicationDelegate
|
||||
{
|
||||
public override UIWindow Window { get; set; }
|
||||
|
||||
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
|
||||
{
|
||||
// Override point for customization after application launch.
|
||||
// If not required for your application you can safely delete this method
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,64 +1,69 @@
|
|||
{
|
||||
"images": [
|
||||
{
|
||||
"filename": "Icon-Small.png",
|
||||
"size": "29x29",
|
||||
"scale": "1x",
|
||||
"size": "20x20",
|
||||
"scale": "2x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"filename": "Icon-Small@2x.png",
|
||||
"size": "20x20",
|
||||
"scale": "3x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"filename": "icon-spotlight-29@2x.png",
|
||||
"size": "29x29",
|
||||
"scale": "2x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"filename": "icon-spotlight-29@3x.png",
|
||||
"size": "29x29",
|
||||
"scale": "3x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"filename": "Icon-Spotlight-40@2x.png",
|
||||
"filename": "icon-spotlight-40@2x.png",
|
||||
"size": "40x40",
|
||||
"scale": "2x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"filename": "Icon-60@2x.png",
|
||||
"filename": "icon-spotlight-40@3x.png",
|
||||
"size": "40x40",
|
||||
"scale": "3x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"filename": "Icon.png",
|
||||
"size": "57x57",
|
||||
"scale": "1x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"filename": "Icon@2x.png",
|
||||
"size": "57x57",
|
||||
"scale": "2x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"filename": "Icon-60@2x.png",
|
||||
"filename": "icon-app-60@2x.png",
|
||||
"size": "60x60",
|
||||
"scale": "2x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"filename": "Icon-60@3x.png",
|
||||
"filename": "Icon-app-60@3x.png",
|
||||
"size": "60x60",
|
||||
"scale": "3x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"size": "20x20",
|
||||
"scale": "1x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"size": "20x20",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"filename": "icon-spotlight-29.png",
|
||||
"size": "29x29",
|
||||
"scale": "1x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"filename": "icon-spotlight-29@2x.png",
|
||||
"size": "29x29",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
|
@ -69,40 +74,45 @@
|
|||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"filename": "icon-spotlight-40@2x.png",
|
||||
"size": "40x40",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"size": "50x50",
|
||||
"scale": "1x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"size": "50x50",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"size": "72x72",
|
||||
"scale": "1x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"size": "72x72",
|
||||
"filename": "Icon-app-83.5@2x.png",
|
||||
"size": "83.5x83.5",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"filename": "icon-app-76.png",
|
||||
"size": "76x76",
|
||||
"scale": "1x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"filename": "icon-app-76@2x.png",
|
||||
"size": "76x76",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"filename": "app-store-logo.png",
|
||||
"size": "1024x1024",
|
||||
"scale": "1x",
|
||||
"idiom": "ios-marketing"
|
||||
},
|
||||
{
|
||||
"size": "60x60",
|
||||
"scale": "2x",
|
||||
"idiom": "car"
|
||||
},
|
||||
{
|
||||
"size": "60x60",
|
||||
"scale": "3x",
|
||||
"idiom": "car"
|
||||
},
|
||||
{
|
||||
"role": "notificationCenter",
|
||||
"size": "24x24",
|
||||
|
@ -137,9 +147,16 @@
|
|||
"idiom": "watch"
|
||||
},
|
||||
{
|
||||
"role": "longLook",
|
||||
"role": "appLauncher",
|
||||
"size": "44x44",
|
||||
"subtype": "42mm",
|
||||
"subtype": "40mm",
|
||||
"scale": "2x",
|
||||
"idiom": "watch"
|
||||
},
|
||||
{
|
||||
"role": "appLauncher",
|
||||
"size": "50x50",
|
||||
"subtype": "44mm",
|
||||
"scale": "2x",
|
||||
"idiom": "watch"
|
||||
},
|
||||
|
@ -158,16 +175,70 @@
|
|||
"idiom": "watch"
|
||||
},
|
||||
{
|
||||
"size": "120x120",
|
||||
"role": "quickLook",
|
||||
"size": "108x108",
|
||||
"subtype": "44mm",
|
||||
"scale": "2x",
|
||||
"idiom": "watch"
|
||||
},
|
||||
{
|
||||
"size": "1024x1024",
|
||||
"scale": "1x",
|
||||
"idiom": "car"
|
||||
"idiom": "watch-marketing"
|
||||
},
|
||||
{
|
||||
"size": "16x16",
|
||||
"scale": "1x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "16x16",
|
||||
"scale": "2x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "32x32",
|
||||
"scale": "1x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "32x32",
|
||||
"scale": "2x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "128x128",
|
||||
"scale": "1x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "128x128",
|
||||
"scale": "2x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "256x256",
|
||||
"scale": "1x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "256x256",
|
||||
"scale": "2x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "512x512",
|
||||
"scale": "1x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "512x512",
|
||||
"scale": "2x",
|
||||
"idiom": "mac"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
"version": 1,
|
||||
"author": "xcode"
|
||||
},
|
||||
"properties": {
|
||||
"pre-rendered": true
|
||||
}
|
||||
}
|
Двоичные данные
DispatchSourceExamples/DispatchSourceExamples/Assets.xcassets/AppIcon.appiconset/Icon-app-60@3x.png
Normal file
После Ширина: | Высота: | Размер: 5.0 KiB |
Двоичные данные
DispatchSourceExamples/DispatchSourceExamples/Assets.xcassets/AppIcon.appiconset/Icon-app-83.5@2x.png
Normal file
После Ширина: | Высота: | Размер: 8.6 KiB |
Двоичные данные
DispatchSourceExamples/DispatchSourceExamples/Assets.xcassets/AppIcon.appiconset/app-store-logo.png
Normal file
После Ширина: | Высота: | Размер: 22 KiB |
Двоичные данные
DispatchSourceExamples/DispatchSourceExamples/Assets.xcassets/AppIcon.appiconset/icon-app-60@2x.png
Normal file
После Ширина: | Высота: | Размер: 3.3 KiB |
Двоичные данные
DispatchSourceExamples/DispatchSourceExamples/Assets.xcassets/AppIcon.appiconset/icon-app-76.png
Normal file
После Ширина: | Высота: | Размер: 2.0 KiB |
Двоичные данные
DispatchSourceExamples/DispatchSourceExamples/Assets.xcassets/AppIcon.appiconset/icon-app-76@2x.png
Normal file
После Ширина: | Высота: | Размер: 4.3 KiB |
Двоичные данные
DispatchSourceExamples/DispatchSourceExamples/Assets.xcassets/AppIcon.appiconset/icon-spotlight-29.png
Normal file
После Ширина: | Высота: | Размер: 900 B |
Двоичные данные
DispatchSourceExamples/DispatchSourceExamples/Assets.xcassets/AppIcon.appiconset/icon-spotlight-29@2x.png
Normal file
После Ширина: | Высота: | Размер: 1.8 KiB |
Двоичные данные
DispatchSourceExamples/DispatchSourceExamples/Assets.xcassets/AppIcon.appiconset/icon-spotlight-29@3x.png
Normal file
После Ширина: | Высота: | Размер: 2.5 KiB |
Двоичные данные
DispatchSourceExamples/DispatchSourceExamples/Assets.xcassets/AppIcon.appiconset/icon-spotlight-40@2x.png
Normal file
После Ширина: | Высота: | Размер: 2.2 KiB |
Двоичные данные
DispatchSourceExamples/DispatchSourceExamples/Assets.xcassets/AppIcon.appiconset/icon-spotlight-40@3x.png
Normal file
После Ширина: | Высота: | Размер: 3.3 KiB |
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,309 @@
|
|||
using CoreFoundation;
|
||||
using DispatchSourceExamples.Models;
|
||||
using Foundation;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UIKit;
|
||||
|
||||
namespace DispatchSourceExamples
|
||||
{
|
||||
public partial class DetailsViewController : UIViewController
|
||||
{
|
||||
private const long NanosecondsInSecond = 1000000000;
|
||||
|
||||
private DispatchSource dispatchSource;
|
||||
|
||||
private NSUrl testFileUrl;
|
||||
|
||||
private bool isActive;
|
||||
|
||||
public DetailsViewController(IntPtr handle) : base(handle) { }
|
||||
|
||||
public DispatchSourceItem DispatchItem { get; internal set; }
|
||||
|
||||
protected NSUrl TestFileUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
if (testFileUrl == null)
|
||||
{
|
||||
var fileUrl = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User).FirstOrDefault();
|
||||
if (fileUrl != null)
|
||||
{
|
||||
using (fileUrl)
|
||||
{
|
||||
testFileUrl = fileUrl.Append("test.txt", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return testFileUrl;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ViewDidLoad()
|
||||
{
|
||||
base.ViewDidLoad();
|
||||
|
||||
Title = DispatchItem.Title;
|
||||
UpdateButton();
|
||||
}
|
||||
|
||||
partial void Execute(UIButton sender)
|
||||
{
|
||||
isActive = !isActive;
|
||||
UpdateButton();
|
||||
|
||||
switch (DispatchItem.Type)
|
||||
{
|
||||
case DispatchSourceType.Timer:
|
||||
if (isActive)
|
||||
{
|
||||
StartTimer();
|
||||
}
|
||||
else
|
||||
{
|
||||
CancelDispatchSource();
|
||||
}
|
||||
break;
|
||||
|
||||
case DispatchSourceType.Vnode:
|
||||
if (isActive)
|
||||
{
|
||||
StartVnodeMonitor();
|
||||
}
|
||||
else
|
||||
{
|
||||
TestVnodeMonitor();
|
||||
}
|
||||
break;
|
||||
|
||||
case DispatchSourceType.MemoryPressure:
|
||||
if (isActive)
|
||||
{
|
||||
StartMemoryMonitor();
|
||||
}
|
||||
else
|
||||
{
|
||||
TestMemoryMonitor();
|
||||
}
|
||||
break;
|
||||
|
||||
case DispatchSourceType.ReadMonitor:
|
||||
TestReadMonitor();
|
||||
break;
|
||||
|
||||
case DispatchSourceType.WriteMonitor:
|
||||
StartWriteMonitor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButton()
|
||||
{
|
||||
var title = string.Empty;
|
||||
switch (DispatchItem.Type)
|
||||
{
|
||||
case DispatchSourceType.Timer:
|
||||
title = isActive ? "Stop Timer" : "Start Timer";
|
||||
break;
|
||||
case DispatchSourceType.Vnode:
|
||||
title = isActive ? "Test Vnode Monitor" : "Start Vnode Monitor";
|
||||
break;
|
||||
case DispatchSourceType.MemoryPressure:
|
||||
title = isActive ? "Test Memory Monitor" : "Start Memory Monitor";
|
||||
break;
|
||||
case DispatchSourceType.ReadMonitor:
|
||||
title = "Test Read Monitor";
|
||||
break;
|
||||
case DispatchSourceType.WriteMonitor:
|
||||
title = "Test Write Monitor";
|
||||
break;
|
||||
}
|
||||
|
||||
actionButton.SetTitle(title, UIControlState.Normal);
|
||||
}
|
||||
|
||||
#region Actions
|
||||
|
||||
#region Timer
|
||||
|
||||
private void StartTimer()
|
||||
{
|
||||
var dispatchSourceTimer = new DispatchSource.Timer(DispatchQueue.MainQueue);
|
||||
|
||||
var delay = 2 * NanosecondsInSecond;
|
||||
var leeway = 5 * NanosecondsInSecond;
|
||||
|
||||
dispatchSourceTimer.SetTimer(DispatchTime.Now, delay, leeway);
|
||||
dispatchSourceTimer.SetRegistrationHandler(() => PrintResult("Timer registered"));
|
||||
dispatchSourceTimer.SetEventHandler(() => PrintResult("Timer tick"));
|
||||
dispatchSourceTimer.SetCancelHandler(() => PrintResult("Timer stopped"));
|
||||
|
||||
dispatchSource = dispatchSourceTimer;
|
||||
dispatchSource.Resume();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Vnode
|
||||
|
||||
private void StartVnodeMonitor()
|
||||
{
|
||||
var fileUrl = TestFileUrl;
|
||||
|
||||
var testFileStream = File.Create(fileUrl.Path);
|
||||
int fileDescriptor = GetFileDescriptor(testFileStream);
|
||||
|
||||
var dispatchSourceMonitor = new DispatchSource.VnodeMonitor(fileDescriptor,
|
||||
VnodeMonitorKind.Delete | VnodeMonitorKind.Extend | VnodeMonitorKind.Write,
|
||||
DispatchQueue.MainQueue);
|
||||
|
||||
dispatchSourceMonitor.SetRegistrationHandler(() => PrintResult("Vnode monitor registered"));
|
||||
dispatchSourceMonitor.SetEventHandler(() =>
|
||||
{
|
||||
var observedEvents = dispatchSourceMonitor.ObservedEvents;
|
||||
var message = $"Vnode monitor event for {fileUrl.LastPathComponent}: {observedEvents}";
|
||||
PrintResult(message);
|
||||
|
||||
CancelDispatchSource();
|
||||
testFileStream.Close();
|
||||
});
|
||||
|
||||
dispatchSourceMonitor.SetCancelHandler(() => PrintResult("Vnode monitor cancelled"));
|
||||
|
||||
dispatchSource = dispatchSourceMonitor;
|
||||
dispatchSource.Resume();
|
||||
}
|
||||
|
||||
private void TestVnodeMonitor()
|
||||
{
|
||||
File.Delete(TestFileUrl.Path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Memory Monitor
|
||||
|
||||
private void StartMemoryMonitor()
|
||||
{
|
||||
var dispatchSourcePressure = new DispatchSource.MemoryPressure(MemoryPressureFlags.Critical | MemoryPressureFlags.Warn | MemoryPressureFlags.Normal,
|
||||
DispatchQueue.MainQueue);
|
||||
|
||||
dispatchSourcePressure.SetRegistrationHandler(() => PrintResult("Memory monitor registered"));
|
||||
dispatchSourcePressure.SetEventHandler(() =>
|
||||
{
|
||||
var pressureLevel = dispatchSourcePressure.PressureFlags;
|
||||
PrintResult($"Memory worning of level: {pressureLevel}");
|
||||
CancelDispatchSource();
|
||||
});
|
||||
|
||||
dispatchSourcePressure.SetCancelHandler(() => PrintResult("Memory monitor cancelled"));
|
||||
|
||||
dispatchSource = dispatchSourcePressure;
|
||||
dispatchSource.Resume();
|
||||
}
|
||||
|
||||
private void TestMemoryMonitor()
|
||||
{
|
||||
if (ObjCRuntime.Runtime.Arch == ObjCRuntime.Arch.SIMULATOR)
|
||||
{
|
||||
PrintResult("Press: Debug -> Simulate Memory Warning");
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintResult("This test available on simulator only");
|
||||
CancelDispatchSource();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void TestReadMonitor()
|
||||
{
|
||||
var fileUrl = TestFileUrl;
|
||||
int fileDescriptor = 0;
|
||||
|
||||
using (var stream = new FileStream(fileUrl.Path, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None))
|
||||
{
|
||||
fileDescriptor = GetFileDescriptor(stream);
|
||||
}
|
||||
|
||||
dispatchSource = new DispatchSource.ReadMonitor(fileDescriptor, DispatchQueue.MainQueue);
|
||||
dispatchSource.SetRegistrationHandler(() => PrintResult("Read monitor registered"));
|
||||
dispatchSource.SetEventHandler(() =>
|
||||
{
|
||||
PrintResult($"Read monitor: {fileUrl.LastPathComponent} was opened in read mode");
|
||||
CancelDispatchSource();
|
||||
});
|
||||
|
||||
dispatchSource.SetCancelHandler(() => PrintResult("Read monitor cancelled"));
|
||||
dispatchSource.Resume();
|
||||
}
|
||||
|
||||
private void StartWriteMonitor()
|
||||
{
|
||||
var fileUrl = TestFileUrl;
|
||||
var stream = new FileStream(fileUrl.Path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);
|
||||
int fileDescriptor = GetFileDescriptor(stream);
|
||||
|
||||
dispatchSource = new DispatchSource.WriteMonitor(fileDescriptor, DispatchQueue.MainQueue);
|
||||
dispatchSource.SetRegistrationHandler(() => PrintResult("Write monitor registered"));
|
||||
dispatchSource.SetEventHandler(() =>
|
||||
{
|
||||
PrintResult($"Write monitor: {fileUrl.LastPathComponent} was opened in write mode");
|
||||
CancelDispatchSource();
|
||||
|
||||
stream.Dispose();
|
||||
stream = null;
|
||||
});
|
||||
|
||||
dispatchSource.SetCancelHandler(() => PrintResult("Write monitor cancelled"));
|
||||
dispatchSource.Resume();
|
||||
}
|
||||
|
||||
private void PrintResult(string message)
|
||||
{
|
||||
DispatchQueue.MainQueue.DispatchAsync(() =>
|
||||
{
|
||||
textView.Text = $"{textView.Text}\n{message}";
|
||||
textView.ScrollRangeToVisible(new NSRange(0, textView.Text.Length));
|
||||
});
|
||||
}
|
||||
|
||||
private int GetFileDescriptor(FileStream stream)
|
||||
{
|
||||
var safeHandle = stream.SafeFileHandle;
|
||||
return safeHandle.DangerousGetHandle().ToInt32();
|
||||
}
|
||||
|
||||
private void CancelDispatchSource()
|
||||
{
|
||||
if (dispatchSource != null)
|
||||
{
|
||||
dispatchSource.Cancel();
|
||||
dispatchSource.Dispose();
|
||||
dispatchSource = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (testFileUrl != null)
|
||||
{
|
||||
testFileUrl.Dispose();
|
||||
testFileUrl = null;
|
||||
}
|
||||
|
||||
if (dispatchSource != null)
|
||||
{
|
||||
dispatchSource.Dispose();
|
||||
dispatchSource = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
42
DispatchSourceExamples/DispatchSourceExamples/DetailsViewController.designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,42 @@
|
|||
// WARNING
|
||||
//
|
||||
// This file has been generated automatically by Visual Studio from the outlets and
|
||||
// actions declared in your storyboard file.
|
||||
// Manual changes to this file will not be maintained.
|
||||
//
|
||||
using Foundation;
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using UIKit;
|
||||
|
||||
namespace DispatchSourceExamples
|
||||
{
|
||||
[Register ("DetailsViewController")]
|
||||
partial class DetailsViewController
|
||||
{
|
||||
[Outlet]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
UIKit.UIButton actionButton { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
UIKit.UITextView textView { get; set; }
|
||||
|
||||
[Action ("Execute:")]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
partial void Execute (UIKit.UIButton sender);
|
||||
|
||||
void ReleaseDesignerOutlets ()
|
||||
{
|
||||
if (actionButton != null) {
|
||||
actionButton.Dispose ();
|
||||
actionButton = null;
|
||||
}
|
||||
|
||||
if (textView != null) {
|
||||
textView.Dispose ();
|
||||
textView = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,122 +1,129 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
|
||||
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<ProjectGuid>{A46BC836-0B98-4EB2-AF31-BEEBE5BEFB20}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>DispatchSourceExamples</RootNamespace>
|
||||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
|
||||
<AssemblyName>DispatchSourceExamples</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<MtouchArch>x86_64</MtouchArch>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<MtouchProfiling>true</MtouchProfiling>
|
||||
<MtouchUseRefCounting>true</MtouchUseRefCounting>
|
||||
<MtouchI18n></MtouchI18n>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchArch>ARM64</MtouchArch>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchArch>x86_64</MtouchArch>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhone\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<MtouchArch>ARM64</MtouchArch>
|
||||
<MtouchProfiling>true</MtouchProfiling>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<MtouchUseRefCounting>true</MtouchUseRefCounting>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<MtouchI18n></MtouchI18n>
|
||||
<IpaPackageName></IpaPackageName>
|
||||
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Xamarin.iOS" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Contents.json" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Spotlight-40%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small-50.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small-50%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Spotlight-40.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-72.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-72%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Contents.json" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default-568h%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-60%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-60%403x.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<InterfaceDefinition Include="Main.storyboard" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Info.plist" />
|
||||
<None Include="Entitlements.plist" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<Compile Include="DispatchSourceViewController.cs" />
|
||||
<Compile Include="DispatchSourceViewController.designer.cs">
|
||||
<DependentUpon>DispatchSourceViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MenuViewController.cs" />
|
||||
<Compile Include="MenuViewController.designer.cs">
|
||||
<DependentUpon>MenuViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Test.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\Images.xcassets\LaunchImage.launchimage\" />
|
||||
</ItemGroup>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
|
||||
<ProjectGuid>{339EADEE-24FD-4431-9198-9CED1B8677E6}</ProjectGuid>
|
||||
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>DispatchSourceExamples</RootNamespace>
|
||||
<AssemblyName>DispatchSourceExamples</AssemblyName>
|
||||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
|
||||
<MtouchFastDev>true</MtouchFastDev>
|
||||
<IOSDebuggerPort>28280</IOSDebuggerPort>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<MtouchArch>x86_64</MtouchArch>
|
||||
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
|
||||
<DeviceSpecificBuild>false</DeviceSpecificBuild>
|
||||
<MtouchVerbosity></MtouchVerbosity>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Release</OutputPath>
|
||||
<DefineConstants></DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchUseLlvm>true</MtouchUseLlvm>
|
||||
<MtouchFloat32>true</MtouchFloat32>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<MtouchLink>SdkOnly</MtouchLink>
|
||||
<MtouchArch>ARM64</MtouchArch>
|
||||
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
|
||||
<MtouchVerbosity></MtouchVerbosity>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
|
||||
<DefineConstants></DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<MtouchArch>x86_64</MtouchArch>
|
||||
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
|
||||
<MtouchVerbosity></MtouchVerbosity>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhone\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<DeviceSpecificBuild>true</DeviceSpecificBuild>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
|
||||
<MtouchFastDev>true</MtouchFastDev>
|
||||
<MtouchFloat32>true</MtouchFloat32>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<IOSDebuggerPort>12879</IOSDebuggerPort>
|
||||
<MtouchLink>SdkOnly</MtouchLink>
|
||||
<MtouchArch>ARM64</MtouchArch>
|
||||
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
|
||||
<MtouchVerbosity></MtouchVerbosity>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Xamarin.iOS" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json" />
|
||||
<ImageAsset Include="Assets.xcassets\Contents.json" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\app-store-logo.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon-app-83.5%402x.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\icon-app-76%402x.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\icon-app-76.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\icon-spotlight-29.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\icon-spotlight-29%402x.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\icon-app-60%402x.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon-app-60%403x.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\icon-spotlight-29%403x.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\icon-spotlight-40%402x.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\icon-spotlight-40%403x.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<InterfaceDefinition Include="LaunchScreen.storyboard" />
|
||||
<InterfaceDefinition Include="Main.storyboard" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Info.plist" />
|
||||
<None Include="Entitlements.plist" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<Compile Include="Models\DispatchSourceItem.cs" />
|
||||
<Compile Include="MainViewController.cs" />
|
||||
<Compile Include="MainViewController.designer.cs">
|
||||
<DependentUpon>MainViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DetailsViewController.cs" />
|
||||
<Compile Include="DetailsViewController.designer.cs">
|
||||
<DependentUpon>DetailsViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||
</Project>
|
|
@ -1,330 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using CoreFoundation;
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
namespace DispatchSourceExamples {
|
||||
public enum DispatchSourceType {
|
||||
Timer = 0,
|
||||
Vnode,
|
||||
MemoryMonitor,
|
||||
ReadMonitor,
|
||||
WriteMonitor
|
||||
}
|
||||
|
||||
public partial class DispatchSourceViewController : UIViewController, IUITableViewDelegate, IUITableViewDataSource
|
||||
{
|
||||
const long NanosecondsInSecond = 1000000000;
|
||||
|
||||
bool dispatchSourceIsInUse;
|
||||
DispatchSource dispatchSource;
|
||||
NSUrl testFileUrl;
|
||||
FileStream testFileStream;
|
||||
|
||||
Test CurrentTestInfo { get; set; }
|
||||
|
||||
public DispatchSourceType SelectedDispatchSource { get; set; }
|
||||
|
||||
public NSUrl TestFileUrl {
|
||||
get {
|
||||
if (testFileUrl == null) {
|
||||
using (NSUrl fileURL = NSFileManager.DefaultManager.GetUrls (NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User).First ())
|
||||
testFileUrl = fileURL.Append ("test.txt", false);
|
||||
}
|
||||
|
||||
return testFileUrl;
|
||||
}
|
||||
}
|
||||
|
||||
public DispatchSourceViewController (IntPtr handle) : base (handle)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ViewDidLoad ()
|
||||
{
|
||||
base.ViewDidLoad ();
|
||||
|
||||
Title = SelectedDispatchSource.ToString ();
|
||||
|
||||
switch (SelectedDispatchSource) {
|
||||
case DispatchSourceType.Timer:
|
||||
CurrentTestInfo = new Test {
|
||||
FirstStateText = "Start Timer",
|
||||
SecondStateText = "Stop Timer",
|
||||
FirstAction = StartTimer,
|
||||
SecondAction = CancelDispatchSource
|
||||
};
|
||||
break;
|
||||
case DispatchSourceType.Vnode:
|
||||
CurrentTestInfo = new Test {
|
||||
FirstStateText = "Start Vnode Monitor",
|
||||
SecondStateText = "Test Vnode Monitor",
|
||||
FirstAction = StartVnodeMonitor,
|
||||
SecondAction = TestVnodeMonitor
|
||||
};
|
||||
break;
|
||||
case DispatchSourceType.MemoryMonitor:
|
||||
CurrentTestInfo = new Test {
|
||||
FirstStateText = "Start Memory Monitor",
|
||||
SecondStateText = "Test Memory Monitor",
|
||||
FirstAction = StartMemoryMonitor,
|
||||
SecondAction = TestMemoryMonitor
|
||||
};
|
||||
break;
|
||||
case DispatchSourceType.ReadMonitor:
|
||||
CurrentTestInfo = new Test {
|
||||
FirstStateText = "Test Read Monitor",
|
||||
FirstAction = TestReadMonitor
|
||||
};
|
||||
break;
|
||||
case DispatchSourceType.WriteMonitor:
|
||||
CurrentTestInfo = new Test {
|
||||
FirstStateText = "Test Write Monitor",
|
||||
FirstAction = StartWriteMonitor
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
tableView.DataSource = this;
|
||||
tableView.Delegate = this;
|
||||
}
|
||||
|
||||
public override void ViewWillDisappear(bool animated)
|
||||
{
|
||||
base.ViewWillDisappear (animated);
|
||||
if (testFileStream != null)
|
||||
testFileStream.Dispose ();
|
||||
|
||||
if (dispatchSource != null) {
|
||||
dispatchSource.Cancel ();
|
||||
dispatchSource.Dispose ();
|
||||
}
|
||||
}
|
||||
|
||||
public override void ViewDidLayoutSubviews ()
|
||||
{
|
||||
dynamicViewHeight.Constant = NMath.Min (View.Bounds.Size.Height, tableView.ContentSize.Height);
|
||||
View.LayoutIfNeeded ();
|
||||
}
|
||||
|
||||
void PrintResult (UITextView logView, string message)
|
||||
{
|
||||
DispatchQueue.MainQueue.DispatchAsync (() => {
|
||||
logView.Text = string.Format ("{0}\n{1}", logView.Text, message);
|
||||
textView.ScrollRangeToVisible (new NSRange (0, logView.Text.Length));
|
||||
});
|
||||
}
|
||||
|
||||
[Export ("numberOfSectionsInTableView:")]
|
||||
public int NumberOfSections (UITableView tableView)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
[Export ("tableView:numberOfRowsInSection:")]
|
||||
public nint RowsInSection (UITableView tableview, nint section)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
[Export ("tableView:titleForHeaderInSection:")]
|
||||
public string TitleForHeader (UITableView tableView, int section)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
[Export ("tableView:didSelectRowAtIndexPath:")]
|
||||
public void RowSelected (UITableView tableView, NSIndexPath indexPath)
|
||||
{
|
||||
if (dispatchSourceIsInUse && CurrentTestInfo.SecondAction != null)
|
||||
CurrentTestInfo.SecondAction ();
|
||||
else if (CurrentTestInfo.FirstAction != null)
|
||||
CurrentTestInfo.FirstAction ();
|
||||
|
||||
if (CurrentTestInfo.SecondAction != null)
|
||||
tableView.CellAt (indexPath).TextLabel.Text = dispatchSourceIsInUse ?
|
||||
CurrentTestInfo.FirstStateText : CurrentTestInfo.SecondStateText;
|
||||
|
||||
dispatchSourceIsInUse = !dispatchSourceIsInUse;
|
||||
tableView.DeselectRow (indexPath, true);
|
||||
}
|
||||
|
||||
[Export ("tableView:cellForRowAtIndexPath:")]
|
||||
public UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
|
||||
{
|
||||
string cellIdentifier = "tableCell";
|
||||
|
||||
var cell = tableView.DequeueReusableCell (cellIdentifier);
|
||||
cell = cell ?? new UITableViewCell (UITableViewCellStyle.Subtitle, cellIdentifier);
|
||||
cell.TextLabel.Text = CurrentTestInfo.FirstStateText;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
void StartTimer ()
|
||||
{
|
||||
dispatchSource = new DispatchSource.Timer (DispatchQueue.MainQueue);
|
||||
|
||||
long delay = 2 * NanosecondsInSecond;
|
||||
long leeway = 5 * NanosecondsInSecond;
|
||||
|
||||
((DispatchSource.Timer)dispatchSource).SetTimer (DispatchTime.Now, delay, leeway);
|
||||
|
||||
dispatchSource.SetRegistrationHandler (() => {
|
||||
PrintResult (textView, "Timer registered");
|
||||
});
|
||||
|
||||
dispatchSource.SetEventHandler (() => {
|
||||
PrintResult (textView, "Timer tick");
|
||||
});
|
||||
|
||||
dispatchSource.SetCancelHandler (() => {
|
||||
PrintResult (textView, "Timer stopped");
|
||||
});
|
||||
|
||||
dispatchSource.Resume ();
|
||||
}
|
||||
|
||||
void CancelDispatchSource ()
|
||||
{
|
||||
if (dispatchSource != null)
|
||||
dispatchSource.Cancel ();
|
||||
}
|
||||
|
||||
void StartVnodeMonitor ()
|
||||
{
|
||||
NSUrl fileURL = TestFileUrl;
|
||||
|
||||
testFileStream = File.Create (fileURL.Path);
|
||||
int fileDescriptor = GetFileDescriptor (testFileStream);
|
||||
|
||||
dispatchSource = new DispatchSource.VnodeMonitor (fileDescriptor,
|
||||
VnodeMonitorKind.Delete | VnodeMonitorKind.Extend | VnodeMonitorKind.Write,
|
||||
DispatchQueue.MainQueue
|
||||
);
|
||||
|
||||
dispatchSource.SetRegistrationHandler (() => {
|
||||
PrintResult (textView, "Vnode monitor registered");
|
||||
});
|
||||
|
||||
dispatchSource.SetEventHandler (() => {
|
||||
var observedEvents = ((DispatchSource.VnodeMonitor)dispatchSource).ObservedEvents;
|
||||
string message = string.Format ("Vnode monitor event for {0}: {1}", fileURL.LastPathComponent, observedEvents);
|
||||
PrintResult (textView, message);
|
||||
dispatchSource.Cancel ();
|
||||
testFileStream.Close ();
|
||||
});
|
||||
|
||||
dispatchSource.SetCancelHandler (() => {
|
||||
PrintResult (textView, "Vnode monitor cancelled");
|
||||
});
|
||||
|
||||
dispatchSource.Resume ();
|
||||
}
|
||||
|
||||
void TestVnodeMonitor ()
|
||||
{
|
||||
File.Delete (TestFileUrl.Path);
|
||||
}
|
||||
|
||||
void StartMemoryMonitor ()
|
||||
{
|
||||
dispatchSource = new DispatchSource.MemoryPressure (
|
||||
MemoryPressureFlags.Critical | MemoryPressureFlags.Warn | MemoryPressureFlags.Normal,
|
||||
DispatchQueue.MainQueue);
|
||||
|
||||
dispatchSource.SetRegistrationHandler (() => {
|
||||
PrintResult (textView, "Memory monitor registered");
|
||||
});
|
||||
|
||||
dispatchSource.SetEventHandler (() => {
|
||||
var pressureLevel = ((DispatchSource.MemoryPressure)dispatchSource).PressureFlags;
|
||||
PrintResult (textView, string.Format ("Memory worning of level: {0}", pressureLevel));
|
||||
tableView.UserInteractionEnabled = true;
|
||||
dispatchSource.Cancel ();
|
||||
});
|
||||
|
||||
dispatchSource.SetCancelHandler (() => {
|
||||
PrintResult (textView, "Memory monitor cancelled");
|
||||
});
|
||||
|
||||
dispatchSource.Resume ();
|
||||
}
|
||||
|
||||
void TestMemoryMonitor ()
|
||||
{
|
||||
if (UIDevice.CurrentDevice.Model.Contains ("Simulator")) {
|
||||
PrintResult (textView, "Press: Hardware -> Simulate Memory Warning");
|
||||
tableView.UserInteractionEnabled = false;
|
||||
} else {
|
||||
PrintResult (textView, "This test available on simulator only");
|
||||
dispatchSource.Cancel ();
|
||||
}
|
||||
}
|
||||
|
||||
void StartWriteMonitor ()
|
||||
{
|
||||
NSUrl fileURL = TestFileUrl;
|
||||
var stream = new FileStream (fileURL.Path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);
|
||||
int fileDescriptor = GetFileDescriptor (stream);
|
||||
|
||||
dispatchSource = new DispatchSource.WriteMonitor (fileDescriptor, DispatchQueue.MainQueue);
|
||||
|
||||
dispatchSource.SetRegistrationHandler (() => {
|
||||
PrintResult (textView, "Write monitor registered");
|
||||
});
|
||||
|
||||
dispatchSource.SetEventHandler (() => {
|
||||
string message = string.Format ("Write monitor: {0} was opened in write mode", fileURL.LastPathComponent);
|
||||
PrintResult (textView, message);
|
||||
dispatchSource.Cancel ();
|
||||
stream.Close ();
|
||||
});
|
||||
|
||||
dispatchSource.SetCancelHandler (() => {
|
||||
PrintResult (textView, "Write monitor cancelled");
|
||||
});
|
||||
|
||||
dispatchSource.Resume ();
|
||||
}
|
||||
|
||||
void TestReadMonitor ()
|
||||
{
|
||||
NSUrl fileURL = TestFileUrl;
|
||||
int fileDescriptor = 0;
|
||||
|
||||
using (var stream = new FileStream (fileURL.Path, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None)) {
|
||||
fileDescriptor = GetFileDescriptor (stream);
|
||||
}
|
||||
|
||||
dispatchSource = new DispatchSource.ReadMonitor (fileDescriptor, DispatchQueue.MainQueue);
|
||||
|
||||
dispatchSource.SetRegistrationHandler (() => {
|
||||
PrintResult (textView, "Read monitor registered");
|
||||
});
|
||||
|
||||
dispatchSource.SetEventHandler (() => {
|
||||
PrintResult (textView, string.Format ("Read monitor: {0} was opened in read mode", fileURL.LastPathComponent));
|
||||
dispatchSource.Cancel ();
|
||||
});
|
||||
|
||||
dispatchSource.SetCancelHandler (() => {
|
||||
PrintResult (textView, "Read monitor cancelled");
|
||||
});
|
||||
|
||||
dispatchSource.Resume ();
|
||||
}
|
||||
|
||||
int GetFileDescriptor (FileStream stream)
|
||||
{
|
||||
var safeHandle = stream.SafeFileHandle;
|
||||
IntPtr descriptor = safeHandle.DangerousGetHandle ();
|
||||
return descriptor.ToInt32 ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
// WARNING
|
||||
//
|
||||
// This file has been generated automatically by Xamarin Studio to store outlets and
|
||||
// actions made in the UI designer. If it is removed, they will be lost.
|
||||
// Manual changes to this file may not be handled correctly.
|
||||
//
|
||||
using Foundation;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace DispatchSourceExamples
|
||||
{
|
||||
[Register ("DispatchSourceViewController")]
|
||||
partial class DispatchSourceViewController
|
||||
{
|
||||
[Outlet]
|
||||
UIKit.NSLayoutConstraint dynamicViewHeight { get; set; }
|
||||
|
||||
[Outlet]
|
||||
UIKit.UITableView tableView { get; set; }
|
||||
|
||||
[Outlet]
|
||||
UIKit.UITextView textView { get; set; }
|
||||
|
||||
void ReleaseDesignerOutlets ()
|
||||
{
|
||||
if (tableView != null) {
|
||||
tableView.Dispose ();
|
||||
tableView = null;
|
||||
}
|
||||
|
||||
if (dynamicViewHeight != null) {
|
||||
dynamicViewHeight.Dispose ();
|
||||
dynamicViewHeight = null;
|
||||
}
|
||||
|
||||
if (textView != null) {
|
||||
textView.Dispose ();
|
||||
textView = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,21 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>DispatchSourceExamples</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>Dispatch Source</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.xamarin.dispatch-source-examples</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true />
|
||||
<true/>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>9.0</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
|
@ -25,12 +30,10 @@
|
|||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>XSAppIconAssets</key>
|
||||
<string>Resources/Images.xcassets/AppIcons.appiconset</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.your-company.DispatchSource</string>
|
||||
<key>XSLaunchImageAssets</key>
|
||||
<string>Resources/Images.xcassets/LaunchImage.launchimage</string>
|
||||
<string>Assets.xcassets/AppIcon.appiconset</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Xamarin" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Dyv-IY-bna">
|
||||
<rect key="frame" x="116" y="320" width="142" height="48"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="40"/>
|
||||
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstItem="Dyv-IY-bna" firstAttribute="centerY" secondItem="XFU-tI-aps" secondAttribute="centerY" id="4My-kq-iUf"/>
|
||||
<constraint firstItem="Dyv-IY-bna" firstAttribute="centerX" secondItem="XFU-tI-aps" secondAttribute="centerX" id="RWn-d8-9cm"/>
|
||||
</constraints>
|
||||
<viewLayoutGuide key="safeArea" id="XFU-tI-aps"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="53" y="375"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
namespace DispatchSourceExamples
|
||||
{
|
||||
public class Application
|
||||
{
|
||||
// This is the main entry point of the application.
|
||||
static void Main (string[] args)
|
||||
{
|
||||
// if you want to use a different Application Delegate class from "AppDelegate"
|
||||
// you can specify it here.
|
||||
UIApplication.Main (args, null, "AppDelegate");
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Application
|
||||
{
|
||||
// This is the main entry point of the application.
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// if you want to use a different Application Delegate class from "AppDelegate"
|
||||
// you can specify it here.
|
||||
UIApplication.Main(args, null, "AppDelegate");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,226 +1,132 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7519.1" systemVersion="14A379a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="hCR-MB-san">
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="WKs-V6-qbm">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7513.1"/>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Menu-->
|
||||
<scene sceneID="3Ty-it-iN8">
|
||||
<objects>
|
||||
<tableViewController title="Master" id="012-Vr-XD2" userLabel="Menu" customClass="MenuViewController" sceneMemberID="viewController">
|
||||
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="sDd-bC-0KV">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<sections>
|
||||
<tableViewSection id="42O-tz-TWp">
|
||||
<cells>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="timerCell" textLabel="kOI-kR-4G0" detailTextLabel="DW6-Cv-XmQ" style="IBUITableViewCellStyleSubtitle" id="Lot-ah-fXq">
|
||||
<rect key="frame" x="0.0" y="86" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Lot-ah-fXq" id="sj0-Ym-W0J">
|
||||
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Timer" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="kOI-kR-4G0">
|
||||
<rect key="frame" x="15" y="0.0" width="270" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Submit the event to the target queue" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="DW6-Cv-XmQ">
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="11"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="vnodeCell" textLabel="JME-MI-cuV" detailTextLabel="V0M-CB-WzC" style="IBUITableViewCellStyleSubtitle" id="lnt-Rd-zoO">
|
||||
<rect key="frame" x="0.0" y="86" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="lnt-Rd-zoO" id="z67-rQ-fhk">
|
||||
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Vnode" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="JME-MI-cuV">
|
||||
<rect key="frame" x="15" y="0.0" width="270" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Monitor the filesystem nodes for changes" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="V0M-CB-WzC">
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="11"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="memoryPressureCell" textLabel="qIG-Il-k8q" detailTextLabel="gzH-Ir-Ykr" style="IBUITableViewCellStyleSubtitle" id="ApQ-Yk-fRQ">
|
||||
<rect key="frame" x="0.0" y="86" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ApQ-Yk-fRQ" id="1GK-dU-QwV">
|
||||
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Memory Pressure" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="qIG-Il-k8q">
|
||||
<rect key="frame" x="15" y="0.0" width="270" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Monitor the system memory pressure" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="gzH-Ir-Ykr">
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="11"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="readMonitorCell" textLabel="onY-hT-nDP" detailTextLabel="2DV-bn-Di6" style="IBUITableViewCellStyleSubtitle" id="VUu-Ry-Sxb">
|
||||
<rect key="frame" x="0.0" y="86" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="VUu-Ry-Sxb" id="KlZ-Wa-QbY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Read monitor" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="onY-hT-nDP">
|
||||
<rect key="frame" x="15" y="0.0" width="270" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Monitor file descriptors for pending data" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="2DV-bn-Di6">
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="11"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="writeMonitorCell" textLabel="rqY-V9-oV0" detailTextLabel="aT0-L4-IvD" style="IBUITableViewCellStyleSubtitle" id="x3E-Ca-xVn">
|
||||
<rect key="frame" x="0.0" y="86" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="x3E-Ca-xVn" id="HrY-ZQ-KSw">
|
||||
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Write Monitor" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="rqY-V9-oV0">
|
||||
<rect key="frame" x="15" y="0.0" width="270" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Monitor file descriptors for write buffer space" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="aT0-L4-IvD">
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="11"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
</sections>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="012-Vr-XD2" id="wq8-Ow-mVb"/>
|
||||
<outlet property="delegate" destination="012-Vr-XD2" id="vva-sQ-Pou"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<navigationItem key="navigationItem" title="Dispacth Source" id="VXN-jW-A23"/>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="BzV-Vo-Ocj" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="486" y="123"/>
|
||||
</scene>
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="kOn-WH-nrB">
|
||||
<scene sceneID="gUs-bt-1dM">
|
||||
<objects>
|
||||
<navigationController id="hCR-MB-san" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="VMh-DF-Jlw">
|
||||
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="WKs-V6-qbm" sceneMemberID="viewController">
|
||||
<toolbarItems/>
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="Cqh-kk-dQ3">
|
||||
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
<nil name="viewControllers"/>
|
||||
<connections>
|
||||
<segue destination="012-Vr-XD2" kind="relationship" relationship="rootViewController" id="U0G-3r-5iO"/>
|
||||
<segue destination="aYS-aU-oIY" kind="relationship" relationship="rootViewController" id="Gtz-mP-CwU"/>
|
||||
</connections>
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="KlJ-JW-uPd" sceneMemberID="firstResponder"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="6Fv-Q1-T34" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-260" y="123"/>
|
||||
<point key="canvasLocation" x="218" y="134"/>
|
||||
</scene>
|
||||
<!--Demonstration-->
|
||||
<scene sceneID="bOv-RR-emz">
|
||||
<!--Dispatch Source-->
|
||||
<scene sceneID="XPL-hg-q4d">
|
||||
<objects>
|
||||
<viewController storyboardIdentifier="DSViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="K3I-8J-40Q" userLabel="Demonstration" customClass="DispatchSourceViewController" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="ulK-Qb-Qs8"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="bSO-pF-4IC"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="QoI-u6-WlE">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<tableViewController id="aYS-aU-oIY" customClass="MainViewController" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="FKy-Cz-REg">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<prototypes>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="sourceCellIdentifier" textLabel="4MS-cn-KsD" detailTextLabel="5cM-Tg-7h6" style="IBUITableViewCellStyleSubtitle" id="Wta-8w-w0B">
|
||||
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Wta-8w-w0B" id="txN-XK-SoK">
|
||||
<rect key="frame" x="0.0" y="0.0" width="341" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Timer" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="4MS-cn-KsD">
|
||||
<rect key="frame" x="16" y="5" width="44" height="20.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Subtitle" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="5cM-Tg-7h6">
|
||||
<rect key="frame" x="16" y="25.5" width="44" height="14.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<sections/>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="aYS-aU-oIY" id="C3M-ih-cm0"/>
|
||||
<outlet property="delegate" destination="aYS-aU-oIY" id="hg7-dr-9gT"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<navigationItem key="navigationItem" title="Dispatch Source" id="bsq-K2-AdA"/>
|
||||
<connections>
|
||||
<segue destination="dgr-f2-RPM" kind="show" identifier="openDetailsSegue" id="zC4-ky-sCN"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="KF8-Jv-gPg" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="959" y="134"/>
|
||||
</scene>
|
||||
<!--Details View Controller-->
|
||||
<scene sceneID="MVh-4G-piQ">
|
||||
<objects>
|
||||
<viewController id="dgr-f2-RPM" customClass="DetailsViewController" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="fXa-3z-lRy">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Output:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="TDL-ti-Prj">
|
||||
<rect key="frame" x="20" y="178" width="42" height="15"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ffr-lf-Gbd">
|
||||
<rect key="frame" x="161.5" y="80" width="52" height="34"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="18"/>
|
||||
<state key="normal" title="Action"/>
|
||||
<connections>
|
||||
<action selector="Execute:" destination="dgr-f2-RPM" eventType="touchUpInside" id="265"/>
|
||||
</connections>
|
||||
</button>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Output:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KhK-7B-F5o">
|
||||
<rect key="frame" x="16" y="122" width="58" height="20.5"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="L7P-Vt-iEY">
|
||||
<rect key="frame" x="20" y="193" width="560" height="407"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="qob-bx-prN">
|
||||
<rect key="frame" x="16" y="150.5" width="343" height="500.5"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textView>
|
||||
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" translatesAutoresizingMaskIntoConstraints="NO" id="OqI-79-fUe">
|
||||
<rect key="frame" x="0.0" y="28" width="600" height="100"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" priority="750" constant="100" id="T1t-u6-xS9"/>
|
||||
</constraints>
|
||||
<sections/>
|
||||
</tableView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstItem="OqI-79-fUe" firstAttribute="top" secondItem="ulK-Qb-Qs8" secondAttribute="bottom" constant="8" symbolic="YES" id="DIY-Jr-ygB"/>
|
||||
<constraint firstAttribute="trailing" secondItem="OqI-79-fUe" secondAttribute="trailing" id="ExD-QJ-HmY"/>
|
||||
<constraint firstItem="bSO-pF-4IC" firstAttribute="top" secondItem="L7P-Vt-iEY" secondAttribute="bottom" id="F58-VS-ScH"/>
|
||||
<constraint firstItem="L7P-Vt-iEY" firstAttribute="top" secondItem="TDL-ti-Prj" secondAttribute="bottom" id="JQC-ho-Jq5"/>
|
||||
<constraint firstItem="L7P-Vt-iEY" firstAttribute="leading" secondItem="QoI-u6-WlE" secondAttribute="leading" constant="20" id="QlF-ov-6s1"/>
|
||||
<constraint firstItem="TDL-ti-Prj" firstAttribute="leading" secondItem="QoI-u6-WlE" secondAttribute="leading" constant="20" id="Sds-MN-uR2"/>
|
||||
<constraint firstItem="OqI-79-fUe" firstAttribute="leading" secondItem="QoI-u6-WlE" secondAttribute="leading" id="hHZ-wt-pa6"/>
|
||||
<constraint firstItem="OqI-79-fUe" firstAttribute="leading" secondItem="QoI-u6-WlE" secondAttribute="leading" id="nsE-Xm-etd"/>
|
||||
<constraint firstAttribute="trailing" secondItem="L7P-Vt-iEY" secondAttribute="trailing" constant="20" id="og5-zi-A0l"/>
|
||||
<constraint firstAttribute="trailing" secondItem="OqI-79-fUe" secondAttribute="trailing" id="rBt-KB-Lc1"/>
|
||||
<constraint firstItem="TDL-ti-Prj" firstAttribute="top" secondItem="OqI-79-fUe" secondAttribute="bottom" constant="50" id="vdq-KA-GOF"/>
|
||||
<constraint firstItem="KhK-7B-F5o" firstAttribute="leading" secondItem="s9d-A3-Jcu" secondAttribute="leading" constant="16" id="JYm-Cs-qRP"/>
|
||||
<constraint firstItem="Ffr-lf-Gbd" firstAttribute="top" secondItem="s9d-A3-Jcu" secondAttribute="top" constant="16" id="Qal-dl-6tf"/>
|
||||
<constraint firstItem="Ffr-lf-Gbd" firstAttribute="centerX" secondItem="s9d-A3-Jcu" secondAttribute="centerX" id="Vfx-MZ-CHQ"/>
|
||||
<constraint firstItem="KhK-7B-F5o" firstAttribute="top" secondItem="Ffr-lf-Gbd" secondAttribute="bottom" constant="8" id="WtT-xf-Dil"/>
|
||||
<constraint firstItem="s9d-A3-Jcu" firstAttribute="trailing" secondItem="qob-bx-prN" secondAttribute="trailing" constant="16" id="dmJ-gq-zNy"/>
|
||||
<constraint firstItem="qob-bx-prN" firstAttribute="top" secondItem="KhK-7B-F5o" secondAttribute="bottom" constant="8" id="dsa-Qk-mp2"/>
|
||||
<constraint firstItem="s9d-A3-Jcu" firstAttribute="bottom" secondItem="qob-bx-prN" secondAttribute="bottom" constant="16" id="msP-rJ-9Gp"/>
|
||||
<constraint firstItem="qob-bx-prN" firstAttribute="leading" secondItem="s9d-A3-Jcu" secondAttribute="leading" constant="16" id="oNn-OP-V5a"/>
|
||||
</constraints>
|
||||
<viewLayoutGuide key="safeArea" id="s9d-A3-Jcu"/>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="dynamicViewHeight" destination="T1t-u6-xS9" id="h7m-IY-Wie"/>
|
||||
<outlet property="tableView" destination="OqI-79-fUe" id="Wid-Qm-22A"/>
|
||||
<outlet property="textView" destination="L7P-Vt-iEY" id="3R8-4a-GBm"/>
|
||||
<outlet property="actionButton" destination="Ffr-lf-Gbd" id="name-outlet-Ffr-lf-Gbd"/>
|
||||
<outlet property="textView" destination="qob-bx-prN" id="name-outlet-qob-bx-prN"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="Rtb-fa-wpr" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="teb-Ro-HFW" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1136" y="123"/>
|
||||
<point key="canvasLocation" x="1681" y="134"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
using DispatchSourceExamples.Models;
|
||||
using Foundation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UIKit;
|
||||
|
||||
namespace DispatchSourceExamples
|
||||
{
|
||||
public partial class MainViewController : UITableViewController
|
||||
{
|
||||
private const string OpenDetailsSegueIndentifier = "openDetailsSegue";
|
||||
private const string CellIdentifier = "sourceCellIdentifier";
|
||||
|
||||
private readonly List<DispatchSourceItem> items = new List<DispatchSourceItem>
|
||||
{
|
||||
new DispatchSourceItem { Type = DispatchSourceType.Timer, Title = "Timer", Subtitle = "Submit the event to the target queue"},
|
||||
new DispatchSourceItem { Type = DispatchSourceType.Vnode, Title = "Vnode", Subtitle = "Monitor the file system nodes for changes"},
|
||||
new DispatchSourceItem { Type = DispatchSourceType.MemoryPressure, Title = "Memory Pressure", Subtitle = "Monitor the system memory pressure"},
|
||||
new DispatchSourceItem { Type = DispatchSourceType.ReadMonitor, Title = "Read Monitor", Subtitle = "Monitor file descriptors for pending data"},
|
||||
new DispatchSourceItem { Type = DispatchSourceType.WriteMonitor, Title = "Write Monitor", Subtitle = "Monitor file descriptors for write buffer space"}
|
||||
};
|
||||
|
||||
private DispatchSourceItem selectedItem;
|
||||
|
||||
public MainViewController(IntPtr handle) : base(handle) { }
|
||||
|
||||
public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
|
||||
{
|
||||
if(!string.IsNullOrEmpty(segue?.Identifier) &&
|
||||
segue.Identifier == OpenDetailsSegueIndentifier)
|
||||
{
|
||||
if(segue.DestinationViewController is DetailsViewController controller)
|
||||
{
|
||||
controller.DispatchItem = selectedItem;
|
||||
selectedItem = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override nint RowsInSection(UITableView tableView, nint section)
|
||||
{
|
||||
return items.Count;
|
||||
}
|
||||
|
||||
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
|
||||
{
|
||||
var item = items[indexPath.Row];
|
||||
|
||||
var cell = tableView.DequeueReusableCell(CellIdentifier, indexPath);
|
||||
cell.TextLabel.Text = item.Title;
|
||||
cell.DetailTextLabel.Text = item.Subtitle;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
|
||||
{
|
||||
selectedItem = items[indexPath.Row];
|
||||
PerformSegue(OpenDetailsSegueIndentifier, this);
|
||||
}
|
||||
}
|
||||
}
|
18
DispatchSourceExamples/DispatchSourceExamples/MainViewController.designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,18 @@
|
|||
// WARNING
|
||||
//
|
||||
// This file has been generated automatically by Visual Studio from the outlets and
|
||||
// actions declared in your storyboard file.
|
||||
// Manual changes to this file will not be maintained.
|
||||
//
|
||||
using Foundation;
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using UIKit;
|
||||
|
||||
namespace DispatchSourceExamples
|
||||
{
|
||||
[Register ("MainViewController")]
|
||||
partial class MainViewController
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
using System;
|
||||
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
namespace DispatchSourceExamples {
|
||||
public partial class MenuViewController : UITableViewController {
|
||||
public MenuViewController (IntPtr handle) : base (handle)
|
||||
{
|
||||
}
|
||||
|
||||
public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
|
||||
{
|
||||
var dsViewController = (DispatchSourceViewController)Storyboard.InstantiateViewController ("DSViewController");
|
||||
dsViewController.SelectedDispatchSource = (DispatchSourceType)indexPath.Row;
|
||||
|
||||
NavigationController.PushViewController (dsViewController, true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
// WARNING
|
||||
//
|
||||
// This file has been generated automatically by Xamarin Studio to store outlets and
|
||||
// actions made in the UI designer. If it is removed, they will be lost.
|
||||
// Manual changes to this file may not be handled correctly.
|
||||
//
|
||||
using Foundation;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace DispatchSourceExamples
|
||||
{
|
||||
[Register ("MenuViewController")]
|
||||
partial class MenuViewController
|
||||
{
|
||||
|
||||
void ReleaseDesignerOutlets ()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
namespace DispatchSourceExamples.Models
|
||||
{
|
||||
public class DispatchSourceItem
|
||||
{
|
||||
public string Title { get; set; }
|
||||
|
||||
public string Subtitle { get; set; }
|
||||
|
||||
public DispatchSourceType Type { get; set; }
|
||||
}
|
||||
|
||||
public enum DispatchSourceType
|
||||
{
|
||||
Timer,
|
||||
Vnode,
|
||||
MemoryPressure,
|
||||
ReadMonitor,
|
||||
WriteMonitor
|
||||
}
|
||||
}
|
До Ширина: | Высота: | Размер: 7.0 KiB |
До Ширина: | Высота: | Размер: 4.5 KiB |
До Ширина: | Высота: | Размер: 5.4 KiB |
До Ширина: | Высота: | Размер: 8.0 KiB |
До Ширина: | Высота: | Размер: 4.4 KiB |
До Ширина: | Высота: | Размер: 6.3 KiB |
До Ширина: | Высота: | Размер: 3.6 KiB |
До Ширина: | Высота: | Размер: 4.7 KiB |
До Ширина: | Высота: | Размер: 4.0 KiB |
До Ширина: | Высота: | Размер: 5.5 KiB |
До Ширина: | Высота: | Размер: 4.7 KiB |
До Ширина: | Высота: | Размер: 6.8 KiB |
|
@ -1,140 +0,0 @@
|
|||
{
|
||||
"images": [
|
||||
{
|
||||
"minimum-system-version": "7.0",
|
||||
"orientation": "portrait",
|
||||
"extent": "full-screen",
|
||||
"filename": "Default@2x.png",
|
||||
"size": "640x960",
|
||||
"scale": "2x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"minimum-system-version": "7.0",
|
||||
"orientation": "portrait",
|
||||
"extent": "full-screen",
|
||||
"filename": "Default-568h@2x.png",
|
||||
"size": "640x1136",
|
||||
"subtype": "retina4",
|
||||
"scale": "2x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"minimum-system-version": "7.0",
|
||||
"orientation": "portrait",
|
||||
"extent": "full-screen",
|
||||
"size": "768x1024",
|
||||
"scale": "1x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"minimum-system-version": "7.0",
|
||||
"orientation": "portrait",
|
||||
"extent": "full-screen",
|
||||
"size": "1536x2048",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"minimum-system-version": "7.0",
|
||||
"orientation": "landscape",
|
||||
"extent": "full-screen",
|
||||
"size": "1024x768",
|
||||
"scale": "1x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"minimum-system-version": "7.0",
|
||||
"orientation": "landscape",
|
||||
"extent": "full-screen",
|
||||
"size": "2048x1536",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"orientation": "portrait",
|
||||
"extent": "full-screen",
|
||||
"filename": "Default.png",
|
||||
"size": "320x480",
|
||||
"scale": "1x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"orientation": "portrait",
|
||||
"extent": "full-screen",
|
||||
"filename": "Default@2x.png",
|
||||
"size": "640x960",
|
||||
"scale": "2x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"orientation": "portrait",
|
||||
"extent": "full-screen",
|
||||
"filename": "Default-568h@2x.png",
|
||||
"size": "640x1136",
|
||||
"subtype": "retina4",
|
||||
"scale": "2x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"orientation": "portrait",
|
||||
"extent": "full-screen",
|
||||
"size": "768x1024",
|
||||
"scale": "1x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"orientation": "portrait",
|
||||
"extent": "full-screen",
|
||||
"size": "1536x2048",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"orientation": "portrait",
|
||||
"extent": "to-status-bar",
|
||||
"size": "768x1004",
|
||||
"scale": "1x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"orientation": "portrait",
|
||||
"extent": "to-status-bar",
|
||||
"size": "1536x2008",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"orientation": "landscape",
|
||||
"extent": "full-screen",
|
||||
"size": "1024x768",
|
||||
"scale": "1x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"orientation": "landscape",
|
||||
"extent": "full-screen",
|
||||
"size": "2048x1536",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"orientation": "landscape",
|
||||
"extent": "to-status-bar",
|
||||
"size": "1024x748",
|
||||
"scale": "1x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"orientation": "landscape",
|
||||
"extent": "to-status-bar",
|
||||
"size": "2048x1496",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
"version": 1,
|
||||
"author": "xcode"
|
||||
}
|
||||
}
|
До Ширина: | Высота: | Размер: 61 KiB |
До Ширина: | Высота: | Размер: 14 KiB |
До Ширина: | Высота: | Размер: 38 KiB |
|
@ -1,43 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6214" systemVersion="14A314h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6207" />
|
||||
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1" />
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" />
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder" />
|
||||
<view contentMode="scaleToFill" id="iN0-l3-epB">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="480" />
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" />
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2015 olegoid" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines"
|
||||
minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
|
||||
<rect key="frame" x="20" y="439" width="441" height="21" />
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17" />
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor" />
|
||||
<nil key="highlightedColor" />
|
||||
</label>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="DispatchSourceExamples" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines"
|
||||
minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
|
||||
<rect key="frame" x="20" y="140" width="441" height="43" />
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="36" />
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor" />
|
||||
<nil key="highlightedColor" />
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite" />
|
||||
<constraints>
|
||||
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC" />
|
||||
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk" />
|
||||
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l" />
|
||||
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0" />
|
||||
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9" />
|
||||
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g" />
|
||||
</constraints>
|
||||
<nil key="simulatedStatusBarMetrics" />
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics" />
|
||||
<point key="canvasLocation" x="548" y="455" />
|
||||
</view>
|
||||
</objects>
|
||||
</document>
|
|
@ -1,14 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace DispatchSourceExamples {
|
||||
public class Test {
|
||||
public string FirstStateText { get; set; }
|
||||
|
||||
public string SecondStateText { get; set; }
|
||||
|
||||
public Action FirstAction { get; set; }
|
||||
|
||||
public Action SecondAction { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,10 @@ Build Requirements
|
|||
|
||||
Building this sample requires Xcode 5.0 and iOS SDK
|
||||
|
||||
License
|
||||
-------
|
||||
Code is released under the MIT license
|
||||
|
||||
Authors
|
||||
------
|
||||
Oleg Demchenko
|
||||
Oleg Demchenko
|
||||
|
|
Двоичные данные
DispatchSourceExamples/Screenshots/1.PNG
До Ширина: | Высота: | Размер: 59 KiB |
Двоичные данные
DispatchSourceExamples/Screenshots/2.PNG
До Ширина: | Высота: | Размер: 31 KiB |
После Ширина: | Высота: | Размер: 87 KiB |
После Ширина: | Высота: | Размер: 54 KiB |