Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static async Task Main(string[] args)
- {
- await Task.Factory.StartNew(DisplayCurrentInfo);
- }
- static async Task DisplayCurrentInfo()
- {
- await WaitAndApologize();
- Console.WriteLine($"The current time is {DateTime.Now.TimeOfDay:t}");
- Thread.Sleep(3000);
- }
- static async Task Main(string[] args)
- {
- await DisplayCurrentInfo(); // or await Task.Run(DisplayCurrentInfo);
- }
- static async Task DisplayCurrentInfo()
- {
- await WaitAndApologize();
- Console.WriteLine($"The current time is {DateTime.Now.TimeOfDay:t}");
- Thread.Sleep(3000);
- }
- static async Task Main(string[] args)
- {
- await Task.Factory.StartNew(DisplayCurrentInfo);
- }
- static async Task DisplayCurrentInfo()
- {
- WaitAndApologize();
- Console.WriteLine($"The current time is {DateTime.Now.TimeOfDay:t}");
- Thread.Sleep(3000);
- }
- static async Task WaitAndApologize()
- {
- // Task.Delay is a placeholder for actual work.
- await Task.Delay(2000);
- // Task.Delay delays the following line by two seconds.
- Console.WriteLine("nSorry for the delay. . . .n");
- }
Add Comment
Please, Sign In to add comment