似乎每次捕获到异常时,都会创建一个新的流程实例。但这对我的朋友来说不会发生。是什么原因造成的?
using System;
using System.Diagnostics;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
Console.WriteLine("Number of process instances: " + Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length);
try {
int b = 0;
int a = 1 / b;
} catch {
};
Console.WriteLine("Number of process instances: " + Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length);
Console.ReadLine();
}
}
}
代码产生以下输出:
Number of process instances: 1
Number of process instances: 2
但是我已经将代码传递给了朋友。他得到以下输出:
Number of process instances: 1
Number of process instances: 1
我正在使用VS2017