Having been kicked out of the basement yet again to develop a little something in the "higher" level code I'm muddling around in the dark and trying to look bright doing it. I need to create a service that will launch mulitple instances of an application (APP) and be able to have some interaction with each APP as well as the service itself (via a serperate application to be developed later - which will be mostly used to add/remove APPs). Just to get the blood flowing, and something started on my desktop, I came up with this little mess...
Process[] p = new Process[portsAL.Count];
NamedPipeServerStream[] pipeServer = new NamedPipeServerStream[portsAL.Count];
for (int i = 0; i < portsAL.Count; i++)
{
p[i] = new Process();
p[i].StartInfo.FileName = appPath;
p[i].StartInfo.Arguments = portsAL[i].ToString();
p[i].Start();
pipeServer[i] = new NamedPipeServerStream("pipe" + portsAL[i].ToString(), PipeDirection.InOut);
pipeServer[i].WaitForConnection();
}
While that actually works (put in a bit-o-code into APP and each instance reported in on its assigned pipe) I will be the first to agree [admit] its not very elegant and I suspect its going to lead to my doing alot more work than my inheritently lazy nature will appreciate. Also, it became clear rather abruptly just how cumbersome it was going to become if I went much farther along these lines. Soooo..... here I am humbly seeking the wisdom of my betters to give me a shove in the right direction.
--------------------------------------------- Help... I'm embedded and I can't get out! If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler