public bool IsBackground { set; get; } Member of System.Threading.ThreadSummary: Gets or sets a value indicating whether or not a thread is a background thread.Returns: true if this thread is or is to become a background thread; otherwise, false.Exceptions: System.Threading.ThreadStateException: The thread is dead.
{ Application.ExitThread();
Application.Exit(); //防止非托管资源未释放造成进程无法消亡 System.Diagnostics.Process CurrentProcess = System.Diagnostics.Process.GetCurrentProcess(); if (CurrentProcess.MainWindowHandle.ToInt32() == 0)
{
try
{
CurrentProcess.Kill();
}
catch
{
}
}
}
线程.IsBackgound = true;
Member of System.Threading.ThreadSummary:
Gets or sets a value indicating whether or not a thread is a background thread.Returns:
true if this thread is or is to become a background thread; otherwise, false.Exceptions:
System.Threading.ThreadStateException: The thread is dead.
{
Thread.CurrentThread.Abort();
}
catch (ThreadAbortException)
{
System.Diagnostics.Process.GetCurrentProcess().Kill();
}
执行
closing事件的时候 _close等于true
timer每次先判断_close是否是true 是的话 停止timer
Application.Exit();
这个应该是可以的