小编Dio*_*sis的帖子

C#程序在for循环中冻结

我在这里有这个代码,开始一个进程等待8秒,然后再次杀死它.

for (int i = 0; i < 20; i++)
{
    Process pro = new Process();
    pro.StartInfo.FileName = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
    pro.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
    pro.Start();

    Thread.Sleep(8000);

    try
    {
        pro.Kill();
        Thread.Sleep(1000);
    }
    catch
    {
        return;
    }
}
Run Code Online (Sandbox Code Playgroud)

当我在调试模式或直接从.exe运行应用程序时,它成功启动并终止进程,但它被冻结.我无法移动窗口或点击其他按钮..

c# freeze

0
推荐指数
1
解决办法
828
查看次数

标签 统计

c# ×1

freeze ×1