using System.Threading.Tasks;
public static async Task Main()
var timeout = Task.Delay(1_000);
var completed = await Task.WhenAny(timeout, task);
if (completed == timeout)
Console.WriteLine("Hey, timeout was hit!!!!!");
throw new Exception("Hit timeout when we shouldn't have");
Console.WriteLine("Running is false");
static async Task SendEvent() {
Console.WriteLine("Took my time, but I'm done now");