0

Possible Duplicate:
Keeping boolean values in sync between two threads

I have a created a new object of my Class Form1 in a thread, although I change a Boolean value called CheckSuccess in the new object - "Form1Object", how do I set the value of CheckSuccess to the GUI / Form?

I.E. I have effectively two copies of a boolean value and I want to set the value of this to the main thread / non object (GUI / Form)

I can't explain it too well, so please let me know if I need to clarify myself

Community
  • 1
  • 1
James Teare
  • 372
  • 1
  • 12
  • 23

1 Answers1

0

Why in the world are you creating a new form object?

If you create two objects, you will have two copies of all the data members those objects contain. There's no good way to synchronize them.

It's not clear why you can't just work with a single form object (instance of the Form1 class). That way, when you modify members on that instance, they will be available to any code that has a reference to that object.

Creating a new form does not accomplish anything with respect to threading. Creating a new form object does not create a new thread. If you provide more information about what problem you're trying to solve and why you think you need to create a new thread in the first place, we could probably give better advice. Perhaps investigate using the BackgroundWorker component? The MSDN page gives an excellent sample of how it might be used.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574