Since VB6 I rarely use the method DoEvents() in C#.
I need to use the same function now for same purpose
I notice that people use this function (Application.DoEvents Method ):
Application.DoEvents()
but this suits Windows Forms.
Now I’m working with WPF.
Is there a similar method in WPF?
Or maybe I shouldn’t use this method anymore?
Thanks.
This.
Basically, the use of
Application.DoEvents()is almost always an indication that you’ve got a long-running task which should be executed on a different thread, calling back to the UI thread where UI access is required.Application.DoEvents()is basically a hack people use when they don’t want to take the time to do things properly – at least in the vast majority of cases.There are various ways of writing long-running tasks which interact with the UI, depending on which versions of the language/framework you’re using, and what your long-running task consists of. Options to consider:
BackgroundWorker