public static async Task <long> TryAwaitCustomType(CancellationToken token) { MyAwaitable test = new MyAwaitable(token); var ret = await test; Console.WriteLine($"Awaitable type calculated {ret} value from long-running job!"); return(ret); }
public MyAwaiter(MyAwaitable awaitable) { _awaitable = awaitable; Task.Run(SetResult).ContinueWith(_ => awaitable.Finish()); }