Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- namespace ProfilingSpike
- {
- class Program
- {
- static void Main(string[] args)
- {
- var task = new MyOperationAsync().GetTheAnswerAsync();
- Task.WaitAll(task);
- }
- }
- public class MyOperationAsync
- {
- public async Task<int> GetTheAnswerAsync()
- {
- Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
- await Task.Delay(5000);
- await DoSomethingElseAsync();
- return 42;
- }
- public async Task DoSomethingElseAsync()
- {
- Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
- await Task.Delay(2000);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement