Not completely.
DoEvents invokes the next message in the application messagequeue, and
can change the codeflow within your current thread (if your on the
application main thread).
Sleep suspends the thread for the specified amount of time, giving
windows time to run other threads.
Sleep(0) just ends the current timeslice for the current thread.
A nice way to see the difference:
do: doevents: loop
gives almost 100% cpu usage, but you can break the process thanks to the
invoke of the messagequeue.
do: sleep(0): loop
gives almost 0% cpu usage, but you cannot break the process (you can end
it with the debugger - in vb6 it will hang your IDE)
So, in short, sleep(x) will make all other applications and other
threads in your application more responsive, except for the thread your
code is running on (if this is the application main thread, your
application will not be more responsive, and may even be seen as not
responding in the task manager).
The main thread of your application can only made to be more responsive
by using DoEvents or, in your case, the code provided in:
http://www.nirsoft.net/vb/doevents.html
The Grim Reaper wrote:
Import System.Threading, then just use
Thread.Sleep(0)
Does practically the same thing as Application.DoEvents - especially from a
dll.
___________________________
The Grim Reaper
"Woo Mun Foong" <mf***@yahoo.comwrote in message
news:F4**********************************@microsof t.com...
>Hi,
I have a DLL that is used to carry out some lengthly process.
I would like to have something similar to DoEvents that can yield control
back to Windows every now and then.
Any ideas ?
Thank You,
mfwoo