WPF C#键等按钮preSS [英] wpf c# button wait for a button press

查看:144
本文介绍了WPF C#键等按钮preSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧我在编码初学者

所以,我想要做的是谁扣要去等待结果
用户在其他多个按钮,点击其中的一个继续。

So what i'm trying to do is button who gonna wait for
the user to click on one of the multiple other button to continue

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

}

我知道我的英语心不是那么好
非常感谢

I know my english isnt that good Thanks a lot

推荐答案

尝试是这样的:

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;
}

这篇关于WPF C#键等按钮preSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆