TrySetResult() публичный Метод

Attempts to transition the underlying Task into the TaskStatus.RanToCompletion state.
public TrySetResult ( ) : bool
Результат bool
 public static TaskAwaiter<int> GetAwaiter(this Process process)
 {
     var tcs = new TaskCompletionSource<int>();
     process.EnableRaisingEvents = true;
     process.Exited += (s, e) => tcs.TrySetResult(process.ExitCode);
     if (process.HasExited) tcs.TrySetResult(process.ExitCode);
     return tcs.Task.GetAwaiter();
 }