Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用C运行可执行文件的多个实例#_C#_Multithreading_Backgroundworker - Fatal编程技术网

C# 如何使用C运行可执行文件的多个实例#

C# 如何使用C运行可执行文件的多个实例#,c#,multithreading,backgroundworker,C#,Multithreading,Backgroundworker,我一直在寻找一种更好的方法来运行用C#NET编写的多个EXE实例 我已经有一个工作代码,但它的滞后应用程序需要改进。 这是我到目前为止所拥有的 public void startProcess(int Threads) { Random random = new Random(); Thread.Sleep(random.Next(200, 800)); for (int i = 1; i <= Th

我一直在寻找一种更好的方法来运行用C#NET编写的多个EXE实例

我已经有一个工作代码,但它的滞后应用程序需要改进。 这是我到目前为止所拥有的

public void startProcess(int Threads)
        {
            Random random = new Random();
            Thread.Sleep(random.Next(200, 800)); 
            for (int i = 1; i <= Threads; i++)
            {                  
                //Proxy Settings Goes There.......
                Client.find_super_proxy();
                string proxy = Client.super_proxy_ip;
                if (proxy.Length <= 8)
                {
                    Client clnt = new Client();
                    clnt.logout();
                    clnt.login();
                    Client.find_super_proxy();
                    proxy = Client.super_proxy_ip;
                }

                ProcessStartInfo info = new ProcessStartInfo(Path.Combine(Application.StartupPath, "Browse.exe"))
                {
                    Arguments = string.Concat(new object[] { proxy.ToString(), " ", HttpUtility.UrlEncode(txtURL.Text), " ", this.nuInner.Value, " ", random.Next((int)this.nuDelay.Value, (int)this.nuDelay1.Value), " ", this.nuTimeOut.Value, " ", HttpUtility.UrlEncode(userAgent), " ", HttpUtility.UrlEncode(referrer) })
                };
                Process process2 = new Process
                {
                    StartInfo = info,
                    EnableRaisingEvents = true
                };
                process2.Start();
            }

        }
publicsvoidstartProcess(int线程)
{
随机=新随机();
Sleep(random.Next(200800));

对于(int i=1;i而不是
Thread.Sleep()
增加计时器间隔。@ThomasWeller尝试了它,但没有任何价值。请注意,您有
Thread.Sleep()
两次:在
timer2\u Tick()
和在
startProcess()中
。将它们全部删除。这就是阻止用户界面的原因thread@ThomasWeller这在某种程度上对我的事情很重要,比如我想在一点随机延迟后启动另一个实例。啊,我理解:你想要一个缓慢的应用程序,但仍然响应。也许这是有意义的。但对我来说不是。祝你好运。尝试在新的thr中启动流程EAD,但被告知您遇到其他问题,即Purrest.GETByMeMe()不会考虑未启动的进程。
    private void timer2_Tick(object sender, EventArgs e)
    {
        runningthreads = Process.GetProcessesByName("Browse").Length;

        if ( runningthreads < (int)nuThreads.Value )
        {
            int newThread =  (int)nuThreads.Value - runningthreads;
            Random random = new Random();
            Thread.Sleep(random.Next(200, 800));
            startProcess(newThread);

        }

    }