I have a RadForm Dialog that sometimes does some lengthy operations.
In this case, the Form does not always repaint, is that the expected behaviour?
Do I always have to implement some Worker Thread pattern when working with RadForm?
1 Answer, 1 is accepted
answered on 30 Dec 2008, 12:29 PM
Thank you for your question.
In Windows Forms the thread that handles the messages from the operating system to the current application also runs the logic that this messages trigger. In other words, when a Windows Form receives a message that it should repaint, the thread that receives the message also runs the paint logic which will repaint the form. Therefore, when lengthy operations are run in a Windows Application the messages that are sent to your application have to wait until these operations are finished which can sometimes lead to undesired appearance of a Windows Form, since it cannot repaint on time.
The simplest way to workaround this problem is to call Application.DoEvents() within the lengthy operation, if of course you have control over operation's logic. You should be mindful when using DoEvents() as it may cause execution of user input event handlers and so on.
The other solution would be as you guessed, to use a separate thread.
I hope this answers your question.
Do not hesitate to write back if you have any further questions.
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.