Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading.Tasks;
- using System.Timers;
- namespace ConsoleApplication1
- {
- internal class Program
- {
- public static async Task Main(string[] args)
- {
- Console.WriteLine("Before await");
- await SomeAsyncCode();
- Console.WriteLine("After await");
- }
- public static Task SomeAsyncCode()
- {
- var tcs = new TaskCompletionSource<bool>();
- var timer = new Timer();
- timer.Interval = 5000;
- timer.Elapsed += (sender, args) => tcs.SetResult(true);
- timer.Enabled = true;
- return tcs.Task;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement