Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming this is a WinForms application, one fairly hackish approach is to call <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.application.doevents.aspx" rel="nofollow">Application.DoEvents()</a> periodically inside your intensive work that's running on the UI thread. This allows the message pump to process pending messages in the midst of your logic. Note that this is fraught with its own set of perils, such as:</p> <ol> <li><p>All UI events can fire, which means you have have things like button presses triggering long-running UI updates, which subsequently block your previous UI work that yielded with DoEvents(). A particularly insidious form of this is when you 'double click' a Button, which spins up a long operation, which yields to DoEvents(), which handles another button click and spins up the same operation, which runs until completion, then returns control back to the first button click handler in the middle of its operation. What this means is that you have to be very careful with what UI interaction you allow during these 'long-running' operations on the UI thread.</p></li> <li><p>Because the user can interact with the UI, it's possible they can invalidate assumptions that your code previously made about things not changing. Again, it's critical to limit what the user can do so that they can't invalidate the state your operation depends on. Of course, you run into the same problem with code running in another thread.</p></li> <li><p>This was a fairly common technique back in the days of VB6 (where multi-threading was quite difficult to do), but it's frowned upon in modern development. It might get you out of a tight spot in your legacy application, but I recommend flagging it with <code>//HACK</code> tags for future cleanup.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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