Re: time delay



Pick any value for your delay. I can guarantee that it will be wrong. This is exactly the
WRONG way to wait for an application to enter its message loop. Look at

WaitForInputIdle

which is the correct way to wait for a child process to come up. Note that like all wait
operations, this blocks the waiting thread, so if the thread is a main GUI thread, you
should not do a wait there; instead, you should spawn another thread which does the
WaitForInputIdle and posts a message back to the main GUI thread when the created process
is ready to accept input.

Generally, if you are in a situation where polling is required, you should always rethink
the problem to see if polling can be avoided.

For some details on how to use a separate thread to handle blocking requests and provide
asynchronous notification, see my essay on asynchronous process notification on my MVP
Tips site.
joe

On Thu, 02 Jun 2005 14:36:32 GMT, "GT" <contactGT_remove_@xxxxxxxxxxx> wrote:

>
>"Tim Ward" <tw2@xxxxxxxxxxxx> wrote in message
>news:3g8j7bFb02muU1@xxxxxxxxxxxxxxxxx
>> "GT" <contactGT_remove_@xxxxxxxxxxx> wrote in message
>> news:AwEne.54559$Li.39436@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>>
>>> How can I put a 1 second pause in my program?
>>
>> Why? (Different solutions will be appropriate depending on what you're
>> trying to achieve.)
>
>I am opening another application remotely through OLE and the other
>application requires user input in order to acquire a license. My
>application needs to wait until other application is ready before doing any
>more interactions. I have written a method in the 'other' application's OLE
>interface called "bool waitUntilInitialised()" and in there I can test
>quickly and easily for license validity. I would like to do this test every
>second and only return a value to the 'calling' application when the license
>has been manually validated by the user.
>
>I do not know how to program using multiple threads, so if that might
>simplify the problem perhaps you could advise me where to look (or even
>better, just tell me what to type!!).
>
>Thanks
>

Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.


Loading