What is the necessity of using Application.DoEvents and when we should use it?
What is the necessity of using Application.DoEvents and when we should use it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Application.DoEventsis usually used to make sure that events get handled periodicaly when you’re performing some long-running operation on the UI thread.A better solution is just not to do that. Perform long-running operations on separate threads, marshalling to the UI thread (either using
Control.BeginInvoke/Invokeor withBackgroundWorker) when you need to update the UI.Application.DoEventsintroduces the possibility of re-entrancy, which can lead to very hard-to-understand bugs.