如何自动隐藏消息框?

RKh*_*RKh 5 c#

我想要一个消息框的计时器类型的属性.显示错误后,必须在5秒后无需用户干预消失.

bco*_*sca 9

timer.Interval=5000;
timer.Enabled=true;
MessageBox.Show("Should close automatically");
Run Code Online (Sandbox Code Playgroud)

将以下代码段与计时器的Tick事件处理程序相关联:

private void timer_Tick(object sender,EventArgs evt) {
    timer.Enabled=false;
    SendKeys.Send("{ESC}"); // SendWait as alternative
}
Run Code Online (Sandbox Code Playgroud)