views:

62

answers:

1

Hello,

how to run different tasks in different process?

in my case I will have 2 tasks one runs every 1 mint the other will run every 10 mints

the point is each one is totally independent from the other

how to make them work within the same program?

cheers

+2  A: 

The way I'd do it is to create a Windows Service that contains a Timer. The Timer checks at regular intervals if it is time to run each process, and when it is time to run starts each process using either

  1. The ThreadPool class (if that's what I think you meant by different processes)
  2. A new Process itself. You will have to have each function that needs to run compiled into a seperate executable and then you simply start it using this class.

Hope that helps!

w69rdy
what about BackgroundWorker do I need to take a look at it?
Data-Base
@Data-Base: Thats another option, although the Background Worker's designed for running a time consuming process in the background so that you can keep the UI responsive. Personally I'd go with the ThreadPool but have a read here for an example of the two: http://olivercode.net/2010/02/22/threading-with-the-thread-pool/
w69rdy
Thanks allot :-) ThreadPool seems easy :-) my app is a GUI and each of my functions will run a process (which is an external program), so hmmmmmm
Data-Base
@Data-Base: In that case why not use the ThreadPool to start each process in a new Process http://msdn.microsoft.com/en-us/library/ccf1tfx0.aspx and get each process to WaitForExit http://msdn.microsoft.com/en-us/library/a4b407xt.aspx so you can tell if it is still running or not
w69rdy
that sounds good, with the help of timers :-)
Data-Base