2013-04-08 206 views
-5

好的,我在編碼WPF C#按鈕,等待按下按鈕

初學者那麼我現在要做的是按鈕誰要去等待
用戶點擊其他多個按鈕的一個繼續

void Mainbutton() 
{ 

    //the program run throw so method 

    //Wait for the user to choose one button (I made a numeric pad with buttons) 

    //Then use this information to work 

} 

我知道我的英語心不是那麼好 非常感謝

+0

如果我理解正確,您是否嘗試按下按鈕,我們將其稱爲「開始」,並在點擊另一個按鈕後執行該任務? – Dilshod 2013-04-08 20:50:17

+0

我試圖做一個按鈕,停止在某個點運行,等待用戶點擊其他按鈕,然後繼續 – 2013-04-08 20:54:49

+1

您需要遵循教程;嘗試[這裏](http://msdn.microsoft.com/en-us/library/ms752299.aspx)。 – 2013-04-08 21:00:28

回答

-1

嘗試是這樣的:

bool gotResponse = false; 
//you need to run MainTask in a different thread 
Thread thread = new Thread(new ThreadStart(DoWork)); 
thread.Start(); 

void DoWork() 
{ 
    //do some work 
    //when something else needed from user then popup message 
    MessageBox.Show("say whatever you need to say"); 
    while(!gotResponse) 
    { 
      //note: this loop doesn't stop until gotResponse = true; 
    } 
    //do rest of your work 
} 

private button_Click(object sender, RoutedEventArgs e) 
{ 
    gotResponse = true; 
}