Search code examples
c#winformspopupbusyindicator

WinForms: Looking for an easy way to pop up a 'Processing..' panel


I have a WinForms application that, at some point, will do some calculations that take a couple of seconds. During this time, I disable the controls. Additionally I want to display a popup that kind of 'blocks' the application more visibly.

I tried placing a Panel on top of the Form in order to do so, but there I'm somehow not able to add any text to it. I.e. the Labels and ImageBoxes I put there are somehow not displayed or behind the Panel.

Any suggestions how I could achieve this in a quick and easy way? .. I mean, without redesigning the whole Form.


Solution

  • Your problem with the things not showing up in your additional panel is that everything is happening in the same thread, but your calculations are blocking everything from appearing because they are hogging up the thread. You should look into using a backgroundWorker, which is one of the tools in WinForms. You should throw the function call that performs the calculations into the DoWork method of the backgroundWorker, then the form itself can continue to function during the calculations.

    See http://msdn.microsoft.com/en-us/library/cc221403%28v=vs.95%29.aspx for examples