I am using the BackgroundWorker to do the heavy tasks so the UI thread doesn’t get blocked. While the BackgroundWorker can send values to the UI thread using the progress-scheme, how can the BackgroundWorker get some values FROM the UI thread?
Either by asking it or simply by the UI thread sending some values to the BackgroundWorker?
Just accessing a variable of the UI thread like UIForm.x within the BackgroundWorker does not work, it does not seem to have access to the UI variables???
Many thanks
Other threads than the UI thread are not allowed to access the UI. You probably started the BackgroundWorker with
worker.RunWorkerAsync(). You can also start it withworker.RunWorkerAsync(someObject). While the worker is running, you cannot pass new objects, but you can alter the contents of the object itself. Since object types are reference types, the UI thread and the worker thread will see the same object content.