从我的主要项目中,我主要从当前解决方案运行一些其他可执行文件。
当我怀疑它们不应该退出线程时,输出窗口会向我显示有关退出线程的信息,是什么导致我提出问题,我如何运行我的应用程序子项目以便我可以处理哪个是哪个?
mainApp.exe
, sideProj1.exe
...
在主应用程序中,我执行以下操作:
public static bool LounchSideProj1Exec()
{
/*
here I could simply call it via Process.Start();
or if I could somehow, execute it via thread start,
so I could name the thread and then see it in the output window and other places...
*/
System.Diagnostics.ProcessStartInfo Pinf = new System.Diagnostics.ProcessStartInfo();
var CurMachingMatchsProcs = System.Diagnostics.Process.GetProcesses().Where(p => p.ProcessName.ToLower().Equals("sideproj1"));
//check count, take first, this is a running process of SideProj1 else excute sideProj1:
sideProj1Proc = CurMachingMatchsProcs.First();
// or else...
SideProj1Proc = new System.Diagnostics.Process();
Pinf.FileName = @"G:\...sideProj1.exe";
sideProj1Proc.StartInfo = Pinf;
bool okTh = false;
ThreadStart ths = new ThreadStart(() => { okTh = sideProj1Proc.Start(); });
Thread th = new Thread(ths);
th.Name = "sideProj1THREAD";
th.Start();
}
与..Concert Of Executed projects & main“保持联系”的正确方法是什么?