Guest User

Untitled

a guest
Mar 17th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. public partial class MainWindow : Window
  2. {
  3. public MainWindow()
  4. {
  5. InitializeComponent();
  6. }
  7.  
  8. public static AsyncLocal<object> Test = new AsyncLocal<object>();
  9.  
  10. private void Button_Click(object sender, RoutedEventArgs e)
  11. {
  12. if (Test.Value == null) // same main thread here as well
  13. {
  14. Test.Value = 2; // should not get here?
  15. }
  16. }
  17.  
  18. private void Window_Loaded(object sender, RoutedEventArgs e)
  19. {
  20. Test.Value = 1; // get here on main thread
  21. }
  22. }
Add Comment
Please, Sign In to add comment