Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.Runtime.CompilerServices;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- class Program
- {
- static async Task Main(string[] args)
- {
- var a = await 10;
- Console.WriteLine(a);
- Debugger.Break();
- }
- }
- static class WeirdIntExtension
- {
- public static IntAwaiter GetAwaiter(this int i) => new IntAwaiter();
- internal class IntAwaiter : INotifyCompletion
- {
- private readonly Task _timeoutTask;
- public IntAwaiter()
- {
- _timeoutTask = Task.Delay(TimeSpan.FromSeconds(15));
- Debugger.Break();
- }
- public bool IsCompleted
- {
- get
- {
- Console.WriteLine($"Task status: {_timeoutTask.Status}");
- return _timeoutTask.IsCompleted;
- }
- }
- public void OnCompleted(Action continuation)
- {
- Console.WriteLine("Before continuation");
- continuation();
- Console.WriteLine("After continuation");
- }
- public double GetResult() => 5.5;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement