简体   繁体   中英

How to launch multiple instances of an exe appln using threads in a single process in c#?

在c#中,我想在一个进程中启动同一个exe应用程序的多个实例,每个实例必须在一个进程中作为不同的线程运行。

最有可能的是,您需要的是App Domains

Explaining what you're trying to achieve will help understand the problem a little better, but one approach could be:

Code your application to check if it's already running; if it is, pass a message to that application telling it to create a new thread (with any parameters passed to this new instance) and then exit leaving the other process running the threads doing the work.

Of course, if you have applications that spawn your app waiting for it to exit will require a change to the above as the application in my suggestion will exit quickly if another instance is running. You will also have to code to handle cases where the application crashes/locks up - this could block following instances of the application from telling it to run new threads.

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