public MacFileSystemWatcher(string filePath) { System.Diagnostics.Debug.WriteLine("Creating MacFileSystemWatcher"); _eventStream = new FSEventStream(new[] { filePath }, TimeSpan.FromMilliseconds(500), FSEventStreamCreateFlags.FileEvents); _eventStream.Events += OnFSEventStreamEvents; _eventStream.ScheduleWithRunLoop(NSRunLoop.Current); _eventStream.Start(); }
public void FSEventFileChangedTest() { string path = Path.Combine(dirPath, "TempFileToWatch.txt"); var taskCompletionSource = new TaskCompletionSource <FSEventStreamEventsArgs> (); FSEventStreamEventsArgs args = null; TestRuntime.RunAsync(TimeSpan.FromSeconds(30), async() => { fsEventStream.Events += (sender, eventArgs) => { taskCompletionSource.SetResult(eventArgs); watchedFileChanged = true; }; fsEventStream.ScheduleWithRunLoop(CFRunLoop.Current); fsEventStreamStarted = fsEventStream.Start(); File.AppendAllText(path, "Hello World!"); Assert.IsTrue(File.Exists(path)); args = await taskCompletionSource.Task.ConfigureAwait(false); }, () => watchedFileChanged); Assert.IsNotNull(args, "Null args"); }
public FileSystemWatcher(string path, bool includeSubdirectories) { if (!includeSubdirectories) { Filter = (s) => { return System.IO.Path.GetDirectoryName(s) == path; }; } fsEventStream = new FSEventStream( new string[] { path }, TimeSpan.FromSeconds(1), FSEventStreamCreateFlags.FileEvents | FSEventStreamCreateFlags.IgnoreSelf); fsEventStream.Events += handleEvents; fsEventStream.ScheduleWithRunLoop(NSRunLoop.Current); fsEventStream.Start(); }
void ToggleFSEventStream() { if (eventStreamIsRunning) { eventStream.Stop(); eventStreamIsRunning = false; StartStopButton.Title = "Start"; } else { eventStream.Start(); eventStreamIsRunning = true; StartStopButton.Title = "Stop"; } }
private void OnFSEventStreamEvents(object sender, FSEventStreamEventsArgs e) { _eventStream.Stop(); System.Diagnostics.Debug.WriteLine("Received an event"); foreach (var ev in e.Events) { System.Diagnostics.Debug.WriteLine(ev.Flags); System.Diagnostics.Debug.WriteLine(ev.Path); } var t = new EventArgs(); Events?.Invoke(this, t); _eventStream.Start(); }
void StartMonitoringExternalCssChanges() { if (fsEventStream != null) { return; } var monitorPaths = new [] { ClientApp.SharedInstance.WebServer.SourceBasePath.FullPath }; Log.Info(TAG, $"Starting CSS monitor for paths: {string.Join (", ", monitorPaths)}"); fsEventStream = new FSEventStream( monitorPaths, TimeSpan.FromSeconds(1), FSEventStreamCreateFlags.WatchRoot | FSEventStreamCreateFlags.FileEvents); fsEventStream.Events += HandleFSEventStreamEvents; fsEventStream.ScheduleWithRunLoop(NSRunLoop.Current); fsEventStream.Start(); }
public override bool ReadFromUrl (NSUrl url, string typeName, out NSError outError) { fsEvents = new FSEventStream (new [] { Path.GetDirectoryName (url.Path) }, TimeSpan.FromSeconds (0), FSEventStreamCreateFlags.FileEvents); fsEvents.Events += (sender, e) => { foreach (var evnt in e.Events) { if (evnt.Path == url.Path && (evnt.Flags & FSEventStreamEventFlags.ItemModified) != 0) { ReloadDocument (); break; } } }; fsEvents.ScheduleWithRunLoop (NSRunLoop.Current); fsEvents.Start (); documentUrl = url; outError = null; return true; }
public override bool ReadFromUrl(NSUrl url, string typeName, out NSError outError) { fsEvents = new FSEventStream(new [] { Path.GetDirectoryName(url.Path) }, TimeSpan.FromSeconds(0), FSEventStreamCreateFlags.FileEvents); fsEvents.Events += (sender, e) => { foreach (var evnt in e.Events) { if (evnt.Path == url.Path && evnt.Flags.HasFlag(FSEventStreamEventFlags.ItemModified)) { ReloadDocument(); break; } } }; fsEvents.ScheduleWithRunLoop(NSRunLoop.Main); fsEvents.Start(); documentUrl = url; outError = null; return(true); }
public void Start() { isStarted = true; eventStream.Start(); }
public void Start() { _eventStream.Start(); }