Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move FileSystemWatcher initialization to background thread #1631

Merged
merged 2 commits into from
Apr 23, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions resharper/resharper-unity/src/Rider/UnityEditorProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,25 @@ public UnityEditorProtocol(Lifetime lifetime, ILogger logger, UnityHost host,
var protocolInstancePath = solFolder.Combine("Library/ProtocolInstance.json");
protocolInstancePath.Directory.CreateDirectory();

var watcher = new FileSystemWatcher();
watcher.Path = protocolInstancePath.Directory.FullPath;
watcher.NotifyFilter = NotifyFilters.LastWrite; //Watch for changes in LastWrite times
watcher.Filter = protocolInstancePath.Name;
solution.Locks.Tasks.Queue(lf, () =>
{
var watcher = new FileSystemWatcher();
watcher.Path = protocolInstancePath.Directory.FullPath;
watcher.NotifyFilter = NotifyFilters.LastWrite; //Watch for changes in LastWrite times
watcher.Filter = protocolInstancePath.Name;

// Add event handlers.
watcher.Changed += OnChanged;
watcher.Created += OnChanged;
// Add event handlers.
watcher.Changed += OnChanged;
watcher.Created += OnChanged;

lf.Bracket(() => { }, () =>
{
watcher.Dispose();
lf.Bracket(() => { }, () =>
{
watcher.Dispose();
van800 marked this conversation as resolved.
Show resolved Hide resolved
});

watcher.EnableRaisingEvents = true; // Begin watching. Can take significant time to start
});

watcher.EnableRaisingEvents = true; // Begin watching.

// connect on start of Rider
CreateProtocols(protocolInstancePath);
});
Expand Down