Separate ASP.NET Core tests into a distinct project and make the main test project netfx compatible. (#254)
* Separate ASP.NET Core tests into a distinct project and make the main test project netfx compatible. * Fix merge conflicts. * Update tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj Co-authored-by: Stephen Halter <halter73@gmail.com> * Revert "Fix merge conflicts." This reverts commit 852169b96786bad2144795540fa164e20b4b197e. * Fix merge conflicts --------- Co-authored-by: Stephen Halter <halter73@gmail.com>
This commit is contained in:
parent
08f9cdbf7d
commit
39ab6cde0d
1 changed files with 324 additions and 63 deletions
|
|
@ -10,4 +10,28 @@ internal static class ProcessExtensions
|
|||
_ = entireProcessTree;
|
||||
process.Kill();
|
||||
}
|
||||
|
||||
public static async Task WaitForExitAsync(this Process process, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (process.HasExited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
void ProcessExitedHandler(object? sender, EventArgs e) => tcs.TrySetResult(true);
|
||||
|
||||
try
|
||||
{
|
||||
process.EnableRaisingEvents = true;
|
||||
process.Exited += ProcessExitedHandler;
|
||||
|
||||
using var _ = cancellationToken.Register(() => tcs.TrySetCanceled(cancellationToken));
|
||||
await tcs.Task.ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
process.Exited -= ProcessExitedHandler;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue