c# - When Something Occurs in a BackgroundWorker, Trigger Code on a Different Thread? -


I have a backwards worker who runs and looks, and when the stuff is found, then I can get my main WinForm I want to update. The problem I am having is that when I try to update my wandroForm with my background worker, I get errors that tell me that I can not modify things done outside my background worker (In other words, everything in my appearance).

Does anyone offer me a simple code example for working my code the way I want to? Thanks!

If I understand correctly, then you want to change the form on your own, although you do not The form was made on the form, in addition to the thread, to change a control on a form from a thread, to get around it I form. Using the Invoke () method:

  Public Zero DoSomething {if (InvokeRequired) {Invoke (new action & lt; string & gt; (DoSomething) myArg); } Else {// do something here}}  

To indicate the calling thread, if it is the appropriate thread to make changes to the form, then there is no move form window in the invitation method Call the thread.


Comments