Created
September 22, 2018 20:24
-
-
Save adams85/4c59deedc1a1f4f48a3ece52a2a9e3d9 to your computer and use it in GitHub Desktop.
Sample code for https://stackoverflow.com/questions/52457054/c-sharp-task-continuewith-not-working-as-expected/52457672#52457672
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace netcore | |
{ | |
class Program | |
{ | |
static async Task TestAsync() | |
{ | |
// this task or ConfigureAwait(false) affects nothing as long as awaited | |
await Task.Run(() => Console.WriteLine("First task run")).ConfigureAwait(false); | |
var task = Task.Run(() => Thread.Sleep(5000)); | |
await task.ContinueWith(t => Console.WriteLine("Continuation fired")); | |
Console.WriteLine("Done"); | |
} | |
static void Main(string[] args) | |
{ | |
var _ = TestAsync(); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment