Skip to content

Instantly share code, notes, and snippets.

@felipeslongo
Last active February 27, 2019 14:26
Show Gist options
  • Save felipeslongo/5eb5bc52c5ad49b00b872238fa248e5f to your computer and use it in GitHub Desktop.
Save felipeslongo/5eb5bc52c5ad49b00b872238fa248e5f to your computer and use it in GitHub Desktop.
Fire and Forge: How it changes the way the caller works
static void async Main(string[] args)
{
await FireAndForget();
Console.WriteLine("Caller");
FireAndForget();
Console.WriteLine("Caller");
}
public static async Task FireAndForget()
{
Console.WriteLine("Begin FireAndForget");
await Task.Delay(TimeSpan.FromSeconds(5));
Console.WriteLine("End FireAndForget");
}
//Output:
//Begin FireAndForget
//End FireAndForget
//Caller
//Output:
//Begin FireAndForget
//Caller
//End FireAndForget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment