![]() ![]() ![]() The mechanism seemed to work reasonably well and eliminated the typical issues associated with a stalled UI thread. user pressed Escape specifically) that could be used to perform task cancellation (if the background processing thread supported it). Private Sub GenNewPlayersASync() Dim x As Integer 0 Generate the Players on an Async Thread For i As Integer 1 To NumPlayers x i (Sub() CollegePlayers.GenDraftPlayers(x, MyDraft, DraftDT, DraftClass, PosCount)). The DoEvents/Filtering loop also had a simple mechanism that watched for specific events (ex. Any user events performed during the filtered processing were simply discarded. When the background thread finished, the DoEvents loop (with message filtering) was exited and the application went back to normal. This allowed the UI to update/paint (change progress bars, etc.), but the user could not perform any actions since all of the mouse clicks and keypresses were ignored by the message filter. The UI thread would wait until the background thread finished. Long tasks were run in a background thread while the foreground thread continued spinning in Application.DoEvents with the message filter. I once worked on an application (.Net 2.0) that used the Application.DoEvents routine in conjunction with a message filter (IMessageFilter) that let all messages through except mouse clicks, keypresses, and window close requests. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |