Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For your first question, I am not entirely sure, but a review from online seems to show that sometimes this will not throw an exception, but it will not update the label. Is that the case here? Is your label being updated along with having no exception? </p> <p>However, I can answer you second question right now. The <code>ProgressChanged</code> event is meant for exactly what it sounds like. It is supposed to be called to let the UI thread know the status of the backgroundworker so that it can update itself appropriately. The original calling thread (UI in this case) is the one that is used for the <code>ProgressChanged</code>, so when it updates it does not need to call <code>Invoke</code>. But, this should really only be done for showing the progress of a background worker.</p> <p>Now, if it is not an update that you are trying to pass to the calling method, then I would suggest just passing your return data back through the <code>RunWorkerCompleted</code> event. This passes all of your final data back up to the original (UI) thread, so that it can update the UI without any need for an <code>Invoke</code>.</p> <p>So, yes your call to <code>Invoke</code> will work, though. However, understanding what each of the other events are for can help you understand why to use one way over another. Maybe a <code>ProgressChanged</code> event fits better? It can also declutter your code from having unnecessary invokes.</p> <p><strong>Update to first q</strong></p> <p>I still cannot find anything about the toolstrip not needing the invoke. In fact I am finding the opposite using google searches like "toolstriplabel no cross thread exception" or "toolstriplabel invoke", etc. However, as henk mentioned, the toolstriplabel doesn't inherit from control so that might explain why no invoke is required. However, my suggestion is to assume that it will act like any other UI control and make sure it is updated on the UI thread to be safe. <strong>do not rely on quirks</strong>. Better safe than sorry, you never know if things like this might change, especially since it is logically a UI item to most..,</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload