Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. public Form1()
  2. {
  3. InitializeComponent();
  4. CheckForIllegalCrossThreadCalls = true;
  5. }
  6.  
  7. async Task DelayAsync()
  8. {
  9. // GUI context is captured here (right before the following await)
  10. await Task.Delay(3000);//.ConfigureAwait(false);
  11. // As no code follows the preceding await, there is no continuation that uses the captured GUI context.
  12. }
  13.  
  14. private async void Button1_Click(object sender, EventArgs e)
  15. {
  16. Task t = DelayAsync();
  17.  
  18. t.Wait();
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement