SHARE
TWEET

Untitled

a guest Jun 26th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top