简体   繁体   中英

controlling an application solution with multiple multithreaded projects

from my main project I am running some other executables mainly from the current solution.

the output window shows me info on exiting threads when I suspect they shouldn't, what leads me to the question, how do I run my application child projects so I could process which is which ?

mainApp.exe , sideProj1.exe ...

in main app I do as follows :

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

what is the right approach to "Be In touch" With ..Concert Of Executed projects & main?

so for the issue of recognizing which thread is which

in the constructor of main form

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

according to the project name..

and another thing I did not know is that I could execute the whole solution as starting project, which will accrue only for debug purpose which is good for now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM