using System; using System.Threading.Tasks; public class Example { public static void Main() { var tcs = new TaskCompletionSourceIn this example, we create a `TaskCompletionSource(); tcs.Task.ContinueWith(task => Console.WriteLine("Task {0} finished.", task.Id), TaskContinuationOptions.ExecuteSynchronously); tcs.SetResult(42); } }