Application.doevents

RIAS
RIAS used Ask the Experts™
on
Hello,
Is there a better and faster way of Application.doevents
Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
in which scenario are you using DoEvents? That will never speed up an application, it will only give some time to other thread like the UI thread to update

Author

Commented:
Thanks! Its mainly about when the screen is refeeshing
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
there isn't much you can do (other then calling DoEvents) or you need to introduce tasking
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Freelance programmer / Consultant
Commented:
DoEvents is a built in hack.  As you realise it is to allow the UI to handle events (actually messages) whilst the UI main thread is otherwise busy.

If you have computationally intensive tasks then they ideally should be performed in another thread - so the UI remains responsive and there is no need to use DoEvents.
Vaughn BighamSr. Software Engineer / Architect

Commented:
Similar to other comments, I would recommend putting the intensive processing into another thread so you shouldn't need to call Application.DoEvents() at all. You could use a background worker, ThreadPool.QueueUserWorkItem, task parallel library (aka async/await). I think async/await is probably the most familiar pattern for other programmers lately.

Author

Commented:
Is system.windows.forms.application.doevents better ? than just Application.doevents?
AndyAinscowFreelance programmer / Consultant

Commented:
The same.

Author

Commented:
Thanks Andy!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial