Run method in new process
.net, c#, process
Solution
Processes do not share memory and require a mechanism between them to communicate. You can use one of a variety mechanisms for this:
- File or data - one process writes to a file or DB, the other reads from and executes some method based on the data or file content
- Service host/client - use WCF, .NET Remoting, Named Pipes or direct TCP/IP communication mechanism where one process hosts a service interface implementation and the calling process (the client) uses a proxy of the service interface to serialize and communicate the call to the host process - this is the best approach if you want a stateful request/response interaction
- Message queue - use a message queue like MSMQ where one process sends a message to the queue and the other picks it up and executes the method
I'm sure there are others but these are the three most common methods.
My favorite is a light weight service host/client scenario. There are several lightweight utilities to make this easy for you. You can use RemotingLite or my own extension of RemotingLite which supports Named Pipes called DuoVia.Net.
Problem
is it possible to run method in new child process? In my example I can execute method Run, which will execute private method doAction in new process (not thread!) ``` public class MyClass { public void Run() { //what should I do there to run 'doAction' in new process? doAction(); } private void doAction() { ... } } ```