I traditionally have a lot of trouble with BackgroundWorkers in C# for some reason; their concept really seems to stump me, so I'm hoping this is a fairly basic issue and something the can be corrected easily enough...
I have two forms that use .NET remoting to communicate back and forth. Right now, changing a setting on Form1 causes something to change on Form2 and that works great. However, now I need to make the same thing work the other way (changing something on Form2 causes Form1 to update) and I can't do it the same way (I cannot, due to restrictions in the design, have Form2 send the change to Form1). Right now, I'm trying to use a BackgroundWorker on Form1 to constantly call an 'Update()' method on each of the subcontrols (which are placed on Form1). Each of these controls have the means to grab the current state of their equalivalent settings from Form2 and update themselves (this works well; the 'Update()' method is already seen to be working on the initialization of Form1).
Here's where my issue comes up. I was unsure on how make the BackgroundWorker constantly call 'Update()' on each of the forms, so in my 'DoWork()' method, I have a "while(true)" loop and within that the BackgroundWorker calls the 'Update()' method of each subcontrol, then sleeps for a very short time, then repeats.
Doing it this way, I get an "InvalidOperationException was unhandled by user code" error with details stating that "Cross-thread operation not valid: Control 'comboBox_BGColor' accessed from a thread other than the thread it was created on." Now, I basically know what this means and I understand why it happened, however, I'm unsure what to do differently or how to change things to make it work as desired. Anyone have any tips on this or the way I'm using BackgroundWorker? Thanks a lot for any information and for taking the time to read this!