Skip to content

Commit

Permalink
added SynchronizingObject property to FileWatcherEx
Browse files Browse the repository at this point in the history
  • Loading branch information
d2phap committed Aug 1, 2018
1 parent d7ef116 commit aa1c853
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions Source/DemoApp/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion Source/DemoApp/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,19 @@ private void btnSelectFolder_Click(object sender, EventArgs e)
FolderBrowserDialog f = new FolderBrowserDialog();


if(f.ShowDialog() == DialogResult.OK)
if (f.ShowDialog() == DialogResult.OK)
{
txtPath.Text = f.SelectedPath;

this._fw.Stop();
this._fw.Dispose();
}
}

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
this._fw.Stop();
this._fw.Dispose();
}
}
}
15 changes: 11 additions & 4 deletions Source/FileWatcherEx/FileWatcherEx.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Concurrent;
using System.ComponentModel;
using System.IO;
using System.Threading;

Expand All @@ -14,9 +15,9 @@ public class FileWatcherEx : IDisposable
private Thread _thread;
private EventProcessor _processor;
private BlockingCollection<FileChangedEvent> _fileEventQueue = new BlockingCollection<FileChangedEvent>();
private FileWatcher _watcher;
private FileSystemWatcher _fsw;

private FileWatcher _watcher = new FileWatcher();
private FileSystemWatcher _fsw = new FileSystemWatcher();

#endregion

Expand Down Expand Up @@ -46,7 +47,12 @@ public class FileWatcherEx : IDisposable
/// Gets or sets a value indicating whether subdirectories within the specified path should be monitored.
/// </summary>
public bool IncludeSubdirectories { get; set; } = false;



/// <summary>
/// Gets or sets the object used to marshal the event handler calls issued as a result of a directory change.
/// </summary>
public ISynchronizeInvoke SynchronizingObject { get; set; } = null;

#endregion

Expand Down Expand Up @@ -160,6 +166,7 @@ void onError(ErrorEventArgs e)
this._fsw.Filter = this.Filter;
this._fsw.NotifyFilter = this.NotifyFilter;
this._fsw.IncludeSubdirectories = this.IncludeSubdirectories;
this._fsw.SynchronizingObject = this.SynchronizingObject;

// Start watching
this._fsw.EnableRaisingEvents = true;
Expand Down
4 changes: 2 additions & 2 deletions Source/FileWatcherEx/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]

0 comments on commit aa1c853

Please sign in to comment.