Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyClass
- {
- public Queue variable;
- internal MyClass()
- {
- variable = new Queue<int>();
- variable.Enqueue(1);
- Thread thread = new Thread(new ThreadStart(DoSomething));
- thread.IsBackground = true;
- thread.Start();
- }
- public void DoSomething()
- {
- int i = variable.Dequeue();
- MessageBox.Show(i);
- }
- }
- class MyClass {
- public Queue variable;
- internal MyClass() {
- variable = new Queue();
- variable.Enqueue(1);
- Thread thread = new Thread(new ThreadStart(DoSomething));
- thread.IsBackground = true;
- thread.Start();
- }
- public void DoSomething() {
- int i = (int)(variable.Dequeue()); //cast required here
- //MessageBox may not play nice from non-ui thread
- Console.WriteLine(i);
- }
- }
- public Queue<int> variable;
- MessageBox.Show(i.ToString());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement