Application.DoEvents Vs New Thread

Hi all,

I've a Windows application.It has some complex background task to do when a button is clicked.

When i read the MSDN it says that Application.DoEvents will allow the Windows Forms application to process other events when the complex background task is executing.

I know i can create a Thread to put by background task.

I wonder what are the differences between these 2 approaches When to use what Does Application.DoEvents create threads internally to process application events

Thanks,
Suresh.



Answer this question

Application.DoEvents Vs New Thread

  • Truc Nguyen

    Application.DoEvents() will just explicitly tell the application to process all messages currently in the queue. A new thread will allow your ui thread to continue processing input messages while the worker thread is executing, which something that Application.DoEvents() will not.
    If you have a huge background task and call Application.DoEvents() only after big chunks of work your apllication's response will seem somewhat choppy. Thus I'd rather recommend you to use a secondary thread for doing your work if the task is rather complex.


  • Application.DoEvents Vs New Thread