【问题标题】:controlling an application solution with multiple multithreaded projects控制具有多个多线程项目的应用程序解决方案
【发布时间】:2016-02-17 18:34:51
【问题描述】:

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

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

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“保持联系”的正确方法是什么?

【问题讨论】:

  • 线程“”(0x1a78) 已退出,代码为 0 (0x0)。

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


【解决方案1】:

所以关于识别哪个线程是哪个线程的问题

在主窗体的构造函数中

System.Threading.Thread.CurrentThread.Name = "AppMainTRD";

根据项目名称..

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-13
    相关资源
    最近更新 更多