控制具有多个多线程项目的应用程序解决方案

时间:2016-02-17 18:34:52

标签: c# multithreading visual-studio-2010 logic multiple-projects

从我的主项目

我主要从当前的解决方案运行一些其他可执行文件。

输出窗口向我显示退出线程的信息,当我怀疑他们不应该,导致我的问题,如何运行我的应用程序子项目,以便我可以处理哪个是哪个?

mainApp.exesideProj1.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();
}

“与...保持联系”的正确方法与...已执行项目的对话&主吗

1 个答案:

答案 0 :(得分:0)

所以对于识别哪个线程是哪个

的问题

在主窗体

的构造函数中
System.Threading.Thread.CurrentThread.Name = "AppMainTRD";

根据项目名称..

另一件我不知道的事情是,我可以将整个解决方案作为启动项目来执行,这将仅用于调试目的,这对于现在是好的。