Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. class MyClass
  2. {
  3. public Queue variable;
  4. internal MyClass()
  5. {
  6. variable = new Queue<int>();
  7. variable.Enqueue(1);
  8. Thread thread = new Thread(new ThreadStart(DoSomething));
  9. thread.IsBackground = true;
  10. thread.Start();
  11. }
  12. public void DoSomething()
  13. {
  14. int i = variable.Dequeue();
  15. MessageBox.Show(i);
  16. }
  17. }
  18.  
  19. class MyClass {
  20. public Queue variable;
  21. internal MyClass() {
  22. variable = new Queue();
  23. variable.Enqueue(1);
  24. Thread thread = new Thread(new ThreadStart(DoSomething));
  25. thread.IsBackground = true;
  26. thread.Start();
  27. }
  28. public void DoSomething() {
  29. int i = (int)(variable.Dequeue()); //cast required here
  30. //MessageBox may not play nice from non-ui thread
  31. Console.WriteLine(i);
  32. }
  33. }
  34.  
  35. public Queue<int> variable;
  36.  
  37. MessageBox.Show(i.ToString());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement