In Windows Forms, how to stop the UI thread from blocking when the user presses the scroll button?

No other control is different from the scrollbars of panels, etc. Clicking and holding on a button, labels, links, tabs, no matter what other control has this effect. But as soon as the user clicks on the scroll bar, or clicks and drags the scroll bar, all other processing in the UI thread stops. This is a big problem for my application (a game to keep running in this case), but I can't figure out how to deal with it through overloads, adding calls to Application.DoEvents or something like that. Any thoughts?

+2


source to share


4 answers


Write your own scrollbars / scrollbars. Scrollbars are the ugliest / clunkiest controls in Windows anyway (apart from everyone else).



+1


source


It seems to me that you should try to move your game logic on a different thread (as opposed to having your game logic run inside the main UI thread).



I don't think there is a way to turn off the scrollbars behavior. Unless you create your own controls and provide your own scrolling functionality for containers that need it.

+3


source


Once you start the game, exit the main thread and execute all your business logic, but you will need to address the problem that all winform controls can only be updated by the event thread.

You will need to use InvokeRequired on the controls before replacing them.

This will get you started: http://msdn.microsoft.com/en-us/library/ms171728%28VS.80%29.aspx

+1


source


Or resize it so that scrollbars are unnecessary or move additional functions that they would normally scroll to other controls (menu, button)

0


source







All Articles