Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I create wait states?
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00732145
Message ID:
00734385
Views:
17
Hi Rick,

thanks for joining the thread!

>Usually you shouldn't Sleep any threads for long periods of time, because the Windows Message loop that they're tied to (in the case of EXE servers) can get hung that way.

>Ultimately it's best to use sleep with a short interval of 1000ms and then loop for the number of seconds you want. This way the app is not hung. Usually if you're waiting you need to do this sor tof thing anyway to check for your exit condition, which you shouldn't assume to take a specific amount of time.

>Sleep can also be a problem if the app calling passes its thread context to the called COM object. For example, if you instantiate a COM object from VFP that object (assuming it's a DLL) is launched on the same thread as the calling application, which means you hang that apps main thread. Using Sleep only makes sense if something is happening on a different thread altogether.

Ok! I think I got it ...

Probably "+ the amount of time the task needs" was a little undistinguished ... I only thought about what I'm doing in my Servie/DLL which only takes some seconds. The reason I was asking is an NT Service EXE that makes calls to a COM DLL in a specified interval and I'm currently using a timer in the EXE, so I was thinking of replacing the timer with the Sleep function or adding the sleep function if there are any advantages.

Replacing the timer isn't an option regarding what you're saying (sleep intervals could be up to 5 mins), but would make adding Sleep between the timer interval make any sense to suspend the event loop for a while? BTW: The EXE is VB6.

Thanks + Regards,
Armin

Armin Neudert
Regional Director (Stuttgart) of German FoxPro User Group dFPUG

MCP for Visual FoxPro

Expert/Editor of the VFP section in the German Codezone community portal
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform