Skip to content

Instantly share code, notes, and snippets.

@cbilson
Created December 26, 2012 22:35
Show Gist options
  • Save cbilson/4383667 to your computer and use it in GitHub Desktop.
Save cbilson/4383667 to your computer and use it in GitHub Desktop.
public static class MyExperiment
{
public static void RegularMethod()
{
DoSomethingAsync();
Console.WriteLine("after starting async stuff");
Thread.Sleep(15000);
}
public async static void DoSomethingAsync()
{
Console.WriteLine("before calling async method...");
await DoSomethingSlow(1);
await DoSomethingSlow(2);
Console.WriteLine("after calling task.Result");
}
public static Task DoSomethingSlow(int i)
{
return Task.Factory.StartNew(() =>
{
Thread.Sleep(5000);
Console.WriteLine("{1:MM/dd/yyyy hh:mm:ss.fff tt}: done with {0}", i, DateTime.Now);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment