This code behaves strangely. If I comment the line
Process[] processlist = Process.GetProcesses();
then it works as expected. I see a 'test' message every 2 seconds. If I leave this line, it will print 2-3 'test' messages then stop. What am I doing wrong?
static void processTimerCallback(object x)
{
try
{
Process[] processlist = Process.GetProcesses();
}
catch
{
}
Console.WriteLine("test");
}
static void Main(string[] args)
{
System.Threading.Timer processTimer = new System.Threading.Timer(new TimerCallback(processTimerCallback), null, 2000, 2000);
Application.Run(form = new MainForm());
}