Continuation Task in the same thread as previous

前端 未结 4 516
梦如初夏
梦如初夏 2020-12-16 13:42

I have an WebService that creates a task and a continuation task.

In the first task we set Thread.CurrentPrincipal

Hence, When the Continuat

4条回答
  •  Happy的楠姐
    2020-12-16 14:13

    Call the continuation with TaskScheduler.FromCurrentSynchronizationContext():

    Task UITask= task.ContinueWith(() =>
    {
     this.TextBlock1.Text = "Complete"; 
    }, TaskScheduler.FromCurrentSynchronizationContext());
    

    Copied from https://stackoverflow.com/a/4331287/503969

提交回复
热议问题