Reputation: 1749
I have a question regarding the BackgroundWorker
. I can call the ProgressChanged
event without having started the thread with RunWorkerAsync
.
I don't understand why this works. How can it notify the original thread if the new thread didn't even start yet?
This seems to work regardless, since it updates the GUI without a problem, which wasn't like this before I implemented the BackgroundWorker
.
Upvotes: 2
Views: 725
Reputation: 109862
Calling ReportProgressChanged()
will always raise the ProgressChanged
event regardless of which thread it was called from.
Inside the inplementation of ReportProgressChanged()
is a mechanism which raises the event on the UI thread if it wasn't called from the UI thread. If ReportProgressChanged()
is being called from the UI thread, then it just raises the event without needing to do that extra marshalling.
Upvotes: 7