调用
if (!System.Diagnostics.Debugger.IsAttached)
{
int times = 24 * 3600;
自动重启(times);
}
private static void 自动重启(int times)
{
new System.Timers.Timer(times * 1000)
{
Enabled = true,
AutoReset = true
}.Elapsed += (s, y) =>
{
try
{
//udpServer.Close();
log("定时重启");
Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);
Application.Exit();
Environment.Exit(0);
}
catch (Exception ex)
{
//udpServer.Close();
Environment.Exit(0);
Application.Exit();
}
};
}