Skip to content

Commit 38a5c76

Browse files
committed
fix: don't dispose ManualResetEvent which might be used later
Fixes #261
1 parent a89c61f commit 38a5c76

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/Hosting.CommandLine/Internal/CommandLineLifetime.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal class CommandLineLifetime : IHostLifetime, IDisposable
2020
private readonly ICommandLineService _cliService;
2121
private readonly IConsole _console;
2222
private readonly IUnhandledExceptionHandler? _unhandledExceptionHandler;
23-
private readonly ManualResetEvent _disposeComplete = new ManualResetEvent(false);
23+
private readonly ManualResetEvent _blockProcessExit = new ManualResetEvent(false);
2424

2525
/// <summary>
2626
/// Creates a new instance.
@@ -81,11 +81,11 @@ public Task WaitForStartAsync(CancellationToken cancellationToken)
8181
}
8282
});
8383

84-
// Ensures services are disposed before the application exits.
8584
AppDomain.CurrentDomain.ProcessExit += (_, __) =>
8685
{
8786
_applicationLifetime.StopApplication();
88-
_disposeComplete.WaitOne();
87+
// Ensures services are disposed before the application exits.
88+
_blockProcessExit.WaitOne();
8989
};
9090

9191
// Capture CTRL+C and prevent it from immediately force killing the app.
@@ -100,8 +100,7 @@ public Task WaitForStartAsync(CancellationToken cancellationToken)
100100

101101
public void Dispose()
102102
{
103-
_disposeComplete.Set();
104-
_disposeComplete.Dispose();
103+
_blockProcessExit.Set();
105104
}
106105
}
107106
}

0 commit comments

Comments
 (0)