1

I'm considering options for an app I'm writing. One app spawns multiple copies of another app. I want to be able to call those spawned apps at the end of the day to get status data.

Is it possible to get a list of running processes with the same name and call them to find their id (via a public method) and their status data (via another public method)?

J. Steen
  • 15,470
  • 15
  • 56
  • 63
Dave Tapson
  • 810
  • 1
  • 9
  • 22
  • 1
    You're talking about IPC Inter Process Communication. Have a look at things like MSMQ and HTTP communication. This will allow you simply poll their status for any information! **IF** you have control over the compilation of the other apps. – Callum Linington Jul 22 '16 at 12:50
  • Can't the spawned apps just write their status to stdout for you to parse at the spawning end? – spender Jul 22 '16 at 12:59

1 Answers1

5

A running process is not an assembly; it's the result of an executable assembly being executed on the processor by the operating system.

For example, let's think about an assembly (exe or dll) as a set of instructions for building an RC model plane. The instructions don't ever have to be "run" -- i.e. you don't ever have to build the plane; they could just sit on your book shelf. But once you build the plane, the plane has no notion of what its instructions are or were. The plane is just flying along doing its thing. Now lets say you have a set of instructions for a RC model helicopter. Well, those instructions might reference some information in the model plane instructions for some reason. But you wouldn't expect the helicopter instruction book to ask the built plane for information.

On the other hand, you might build your plane and helicopter ahead of time so that they communicate with one another, maybe to avoid crashing in mid air.

So back to your question: you can't call any methods on a running process (your model plane) because that isn't possible. Even if you called methods on the executable assembly itself, it wouldn't have anything to do with any running instances (processes); the code would be read from the target executable (your plane instructions) and compiled as part of your caller executable (your helicopter instructions).

You can, however, build your executables so they can communicate via Inter-Process Communication (IPC). (There is plenty of information out there on how to do that, just google it.) The difference is the applications are designed beforehand to act together and pass information between each other -- like your model plane and helicopter -- and thus they do that when they are executing.

rory.ap
  • 34,009
  • 10
  • 83
  • 174