CALLING EXE IN A SEPERATE PROCESS THAN THE WINDOWS SERVICE

  • Thread starter Thread starter belgiozen
  • Start date Start date
B

belgiozen

Hi,

I have a working windows service,it is looking for files on the disk
and when some of the files are cupdated it calls an executable. But it
takes a lot of time(about 10 minutes) to run the executable.So while
that executable is running,if I try to stop the windows service while
the executable(MYPROGRAM.EXE) is running,it will wait for a time(about
20 seconds) for the main windows thread to abort.If it does not finish
its work, the service process is killed AUTOMATICALLY and tells
something like "the service did not stop ina timely fashion".
As the windows service will never be able to finish its work under a
minute,
my service always is stooped by WINDOWS and got the message "the
service did not stop ina timely fashion".

I need a asynchronous way to execute the MYPROGRAM.EXE in a different
process than the windows service process so that even if the service
stops,if MYPROGRAM.EXE will continue to run..

One way to do is to call a web service method asynchronously which
executes MYPROGRAM.EXE ...So the .NET code for the windows service
will not suspend when it calls the windows service method. and will
stop ina timely fashion when it is signaled. But I think there should
be better ways of implementing it without using IIS.

I'll appreciate very much if you help...
 
Why do you want to stop the service in the first place? Windows services are
generally ment to run from boot-up to shutdown.
How do you start the external process? A code snippet would help.

Willy.
 
fork a thread in your service's main routine to do that work, then the main
service checking can be happy and you'll get the results you need when they
are ready.
 
The background thread being forked by the main thread will be killed
by the runtime when the service is stopped.So that's not the solution
in my opininion.
Maybe Process Class will help me do that.. starting the exe in a
different process to avoid it being killed even if the service process
stops....




Eric Newton said:
fork a thread in your service's main routine to do that work, then the main
service checking can be happy and you'll get the results you need when they
are ready.

--
Eric Newton
C#/ASP Application Developer
http://ensoft-software.com/
(e-mail address removed)-software.com [remove the first "CC."]

belgiozen said:
Hi,

I have a working windows service,it is looking for files on the disk
and when some of the files are cupdated it calls an executable. But it
takes a lot of time(about 10 minutes) to run the executable.So while
that executable is running,if I try to stop the windows service while
the executable(MYPROGRAM.EXE) is running,it will wait for a time(about
20 seconds) for the main windows thread to abort.If it does not finish
its work, the service process is killed AUTOMATICALLY and tells
something like "the service did not stop ina timely fashion".
As the windows service will never be able to finish its work under a
minute,
my service always is stooped by WINDOWS and got the message "the
service did not stop ina timely fashion".

I need a asynchronous way to execute the MYPROGRAM.EXE in a different
process than the windows service process so that even if the service
stops,if MYPROGRAM.EXE will continue to run..

One way to do is to call a web service method asynchronously which
executes MYPROGRAM.EXE ...So the .NET code for the windows service
will not suspend when it calls the windows service method. and will
stop ina timely fashion when it is signaled. But I think there should
be better ways of implementing it without using IIS.

I'll appreciate very much if you help...
 
Back
Top