« Using MBS to Extend X… | Home | Three weeks till year… »

Unblock menus while threads are running

We recently got our TimerMBS class (22.6 or later) to help in cases, where using a menu on Windows stops your background threads. On macOS and Linux your threads continue to run when the user clicks on the menu and takes a while to make a choice.

So for Windows you can run the following code in your app open event to install a global TimerMBS and have it yield time. This makes sure that your main loop runs at least 10 times a second, even if a menu is open.

Sub Opening() #if TargetWin32 // start timer to yield in order to keep threads running when you use PopupMenus Static timer As TimerMBS timer = New TimerMBS(100, False) timer.Yield = True #EndIf End Sub

Alternatively, you would only enable it, when a thread is running. And then stop it later when the thread is done.

Please try and let us know whether it works well for you.

The biggest plugin in space...
12 12 22 - 08:31