// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
namespace System.Threading.Tasks
{
/// <summary>
public async ValueTask<T> WaitWithCancellationAsync(CancellationToken cancellationToken)
{
_cancellationToken = cancellationToken;
- using (cancellationToken.UnsafeRegister(s => ((TaskCompletionSourceWithCancellation<T>)s).OnCancellation(), this))
+ using (cancellationToken.UnsafeRegister(s => ((TaskCompletionSourceWithCancellation<T>)s!).OnCancellation(), this))
{
return await Task.ConfigureAwait(false);
}
throw;
}
- var tcs = new TaskCompletionSourceWithCancellation<object>();
+ var tcs = new TaskCompletionSourceWithCancellation<bool>();
- EventHandler handler = (s, e) => tcs.TrySetResult(null);
+ EventHandler handler = (s, e) => tcs.TrySetResult(true);
Exited += handler;
try