|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to simulate Application.DoEvents in a DLLHi,
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 =?Utf-8?B?V29vIE11biBGb29uZw==?= <mf***@yahoo.com> wrote in
news:F4D9622B-F1C6-476B-9BC5-1A380E14C671@microsoft.com: Rather than us Application.DoEvents, you call the long running processes > 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. using a delegate or thread. The delegate or thread can be created on the Caller Side... or wrapped in the DLL. The choice is yours. The long running process would raise events to inform the caller of the progress of the process. You'd have to pass a refernce to the function for the application object,
however, why don't you just run the DLL's function in a seperate thread with a call back method to report progress? Show quoteHide quote "Woo Mun Foong" <mf***@yahoo.com> wrote in message news:F4D9622B-F1C6-476B-9BC5-1A380E14C671@microsoft.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 Import System.Threading, then just use
Thread.Sleep(0) Does practically the same thing as Application.DoEvents - especially from a dll. ___________________________ The Grim Reaper Show quoteHide quote "Woo Mun Foong" <mf***@yahoo.com> wrote in message news:F4D9622B-F1C6-476B-9BC5-1A380E14C671@microsoft.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 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: Show quoteHide quote > 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.com> wrote in message > news:F4D9622B-F1C6-476B-9BC5-1A380E14C671@microsoft.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 > >
Need a tip: How do you streamwrite from two different db tables?
Recognizing if SQL Server is installed (and what version) Q: Advice on threads open source .NET search engine? Bootstrapping .NET 2.0 Dispose problem/crash with maximized MDI child windows VB2005 - Split Files Visual Basic Programming - Reference to fpPublishLogInTempDir uri - ADVANCED question "Start external program" no longer works in VS2003 once 2.0 framework installed Uninstall a device |
|||||||||||||||||||||||