Skip to content
Merged
Changes from all commits
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
5 changes: 4 additions & 1 deletion src/MSBuild.UnitTests/MSBuildServer_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,11 @@ public void BuildsWhileBuildIsRunningOnServer()
_env.WithTransientProcess(pidOfServerProcess);

string? dir = Path.GetDirectoryName(markerFile.Path);
using var watcher = new System.IO.FileSystemWatcher(dir!);
// mre must be declared before watcher so that it is disposed after watcher.
// Reversing this order would allow late FileSystemWatcher callbacks to call
// mre.Set() on a disposed ManualResetEvent, causing an ObjectDisposedException.
using ManualResetEvent mre = new ManualResetEvent(false);
using var watcher = new System.IO.FileSystemWatcher(dir!);
watcher.Created += (o, e) =>
{
_output.WriteLine($"The marker file {markerFile.Path} was created. The build task has been started.");
Expand Down
Loading