private static void CancelTcs(object obj) { var tcs = (TaskCompletionSource<bool>) obj; tcs.TrySetCanceled(); } }