4

I would like to know how can I set an operation (method, block of code, etc.) to run on a different PROCESS (not thread) in a way that if the main process crash the others will still be running. Un-monitorable, but running.

I was thinking I could "compile" the block of code in a different app and then execute the result, but that wouldn't be too elegant. Is there a better way?

Leonardo
  • 10,737
  • 10
  • 62
  • 155
  • 2
    .NET App Domains are there for exactly this reason: http://stackoverflow.com/questions/1094478/what-is-a-net-application-domain – Davide Piras Oct 24 '12 at 12:15
  • 1
    Not if the code is likely to throw a SOE from a 3rd party library. In which case AppDomain does not help - the entire process is killed. Whereas having the auxiliary process killed is not as bad. – mark Jan 28 '16 at 19:58

2 Answers2

2

Another option is use the same app/exe and pass command line parameters to signify what to run in the second instance.

Joel Lucsy
  • 8,520
  • 1
  • 29
  • 35
1

Unless you run a separate exe the way ms intends is to create a new appdomain and run the other code in there. http://msdn.microsoft.com/en-us/library/system.appdomain.aspx

Daniel
  • 622
  • 4
  • 6