If you want to communicate between processes in managed code, you
could use WCF with named pipes.  The advantage here is that you can
also publish your status via callbacks.  If you're spawning multiple
of these background threads simultaneously then you'll need to get a
bit more creative.

By looking at your code though you should be able to create a class
that starts a thread and Raises a StatusChanged event and
Shutdown/ProcessingComplete event.  You can run multiple of these
simultaneously without race conditions.  Something like this in a
class:

public void Start(object batchTransmission /* store this somewhere */)
{
        shutdownEvent = new AutoResetEvent(false); // monitor this from
threadProc for cancel.

        proxyThread = new Thread(new ThreadStart(ThreadProc));
        proxyThread.Start();
}

protected void ThreadProc()
{
        // Raise status change events here while processing
}

Since it's running on a webserver you might want to read up on thread
pool and async requests.

- Brian

On Tue, Apr 1, 2008 at 7:41 PM, Clark, Michael (OFM)
<[EMAIL PROTECTED]> wrote:
> If I had a process running in the background (spawned by a web service
>  method, for instance) and wanted another process to be able to get to it
>  to find out what its status was, how would this be done?
>
>  In the specific case, I have an application that is spawned by a web
>  service method running independently of the service.  I want to be able
>  to run another process that will check to see if the spawned app is
>  running in the system, and get its status, preferably from the running
>  application itself.
>
>  My initial design has the spawned app writing its status to a text file
>  as it processes, and the second process checking the file to see what is
>  going on, but I would like to be able to check to see if the spawned
>  process is currently running, and if possible retrieve information from
>  it about its status or operations.
>
>  The web service method starts up the offline process as follows:
>
>  ParameterizedThreadStart pts = new
>  ParameterizedThreadStart(OfflineProcess);
>  Thread proxyThread = new Thread(pts);
>  proxyThread.Start(batchTransmission);
>
>  Whereupon it returns a response to the webservice consumer and
>  terminates while the proxyThread continues to execute in the background.
>  It is this proxyThread I want to communicate with.
>
>  Any ideas?
>
>  Mike
>
>  ===================================
>  This list is hosted by DevelopMentor(R)  http://www.develop.com
>
>  View archives and manage your subscription(s) at http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to