Skip to content

Commit 1721213

Browse files
committed
Fix #6: host.DisposeAsync() を待たずに処理が進んでしまう不具合を修正
1 parent 59bec06 commit 1721213

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Inasync.Hosting.ConsoleHandler/HostBuilderExtensions.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@ public static async Task InvokeAsync(this IHostBuilder hostBuilder, Func<IServic
5555
if (options.ThrowException) { throw; }
5656
}
5757
finally {
58-
// レガシー環境での deadlock 対応: https://github.com/dotnet/corefx/issues/26043
59-
await Task.Run(() => {
60-
if (host is IAsyncDisposable asyncDisposable) {
61-
return asyncDisposable.DisposeAsync();
62-
}
63-
58+
// レガシー環境での deadlock 対応: https://github.com/dotnet/corefx/issues/26043 https://github.com/dotnet/runtime/issues/26165
59+
await Task.Yield();
60+
if (host is IAsyncDisposable asyncDisposable) {
61+
await asyncDisposable.DisposeAsync().ConfigureAwait(false);
62+
}
63+
else {
6464
host.Dispose();
65-
return default;
66-
}).ConfigureAwait(false);
65+
}
6766
}
6867
}
6968
}

0 commit comments

Comments
 (0)