本文介绍了如何通过单击按钮逐个发生多个事件?在订单中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我是C#的新手。



我想制作一个基本的应用程序通过单击一个按钮在不同的文本框中显示两条消息。第二条消息大部分在两秒钟后出现。



我尝试过以下不起作用的代码。确实两条消息都会在两秒钟后立即显示。



我尝试过的事情:



Hello

I am new in C#.

I want to make an basic app that shows two messages in a different text boxes by clicking one button. The second message most be appeared after two seconds.

I have tried the following code that dose not work. Indeed both of the messages are shown at once after two seconds.

What I have tried:

private void btn_play_Click(object sender, RoutedEventArgs e)
        {
                tb_hello.Text = "hello";
                Thread.Sleep(2000);
                tb_goodbye.Text = "goodbye";
        }

推荐答案

private async void btn_play_Click(object sender, RoutedEventArgs e)
       {
           tb_hello.Text = "hello";
           await Task.Delay(2000);
           tb_goodbye.Text = "goodbye";
       }




这篇关于如何通过单击按钮逐个发生多个事件?在订单中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 02:35