Click to See Complete Forum and Search --> : How to create a new thread in VB


Eyal Shiri
January 28th, 1999, 03:12 AM
I have a client and a seperate server (activeX exe set to unattended execution).

I want to be able to terminate the server while it's running.

I invoke a Jam method that runs an infinite loop, and I want to be able to press a stop button that terminates the server. So far, when I call the server I can't access the client anymore!

What do I do?

chee pin
February 10th, 1999, 10:09 PM
Termination of automation server are control the COM object reference count. If you have only one client connect to it and your client has finished using the automation server, the automation server should be exited automatically.


If you have the automation server running in a infinite loop waiting for messages. You can exit the loop (and it is running in local mode) by adding a WaitForSingleObject api call on an Event object into your loop like below:


while WaitForSingleObject(hShutdown, 0) = 0 (psuedo code)

' Do something

wend


And on your client side have the shutdown button do the following:


SetEvent(hShutdown)


Then your server should be able to know that the client has instructed it to exit the infinite loop...