我有下面的代碼:c#如何訪問我的線程?
private void button_Click(object sender, RoutedEventArgs e)
{
Thread t = new Thread(Process);
t.SetApartmentState(ApartmentState.STA);
t.Name = "ProcessThread";
t.Start();
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
string msg = "Really close?";
MessageBoxResult result =
MessageBox.Show(
msg,
"Closing",
MessageBoxButton.YesNo,
MessageBoxImage.Warning);
if (result == MessageBoxResult.No)
{
e.Cancel = true;
}
}
我需要做的代碼工作在私人無效WINDOW_CLOSING只有當它知道那麼ProcessThread還活着/ INPROGRESS /運行..
喜歡的東西IF( GetThreadByName(「ProcessThread」)。IsAlive == true)..
我該如何在C#中編寫它?
太好了!這很簡單,我很白癡:)謝謝! – DefinitionHigh 2011-01-12 12:07:18