|
-
Sep 20th, 2002, 08:53 AM
#10
I think a better solution would be to create a semaphore, with an initial count of 1, and a maximumcount of 1.
Call CreateSemaphore when your app starts, followed by a WaitForSingleObject. If your instance is the first, it will return immediately, otherwise it will wait untill the previous instance called ReleaseSemaphore.
When your app gets closed, call ReleaseSemaphore, followed by a CloseHandle.
This way, you don't have to poll untill you can show your form, the WaitForSingleObject simply returns as soon as it is your turn. Another advantage is that the instances will be running when it is their turn. The second instance will display the form, as soon as the first instance is ready, and the third instance as soon as the second instance is ready. semaphores automatically use the FIFO principle (First In First Out)
I will see if I can write a sample when I get home. I can't spent too much time right now, because i am at work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|