Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 11th, 2012  |  syntax: None  |  size: 0.52 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Threading in WPF [closed]
  2. private void  do_my_method_click(object sender, RoutedEventArgs e)
  3. {  
  4.       //there are some variables and methods here
  5.  
  6.       //works fine
  7.       ThreadPool.QueueUserWorkItem(Start_method);  
  8.  
  9.       // when added gives error this thread owned by other thread
  10.       ThreadPool.QueueUserWorkItem(Start_method_2);
  11. }
  12.  
  13. Start_method(object state)
  14. {
  15. }
  16.  
  17. Start_method_2(object state)
  18. {
  19. }
  20.        
  21. var sync = System.Threading.SynchronizationContext.Current;
  22.  
  23. sync.Post(x => {
  24.  
  25.     TextBlock1.Text = "Foo";
  26.  
  27. }, null);