Skip to content

Instantly share code, notes, and snippets.

@jwChung
Last active September 28, 2017 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwChung/720cd295c350aff8873329c80465c479 to your computer and use it in GitHub Desktop.
Save jwChung/720cd295c350aff8873329c80465c479 to your computer and use it in GitHub Desktop.
class Program
{
static void Main(string[] args)
{
var stopwatch = new Stopwatch();
stopwatch.Start();
RunParallelly().Wait();
stopwatch.Stop();
Console.WriteLine(stopwatch.Elapsed); // 1초
Console.ReadLine();
}
private static async Task RunParallelly()
{
var startedTask = Foo();
await Bar();
await startedTask;
}
private static async Task<int> Foo()
{
await Task.Delay(1000);
return 10;
}
private static async Task<string> Bar()
{
await Task.Delay(1000);
return "bar";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment