按下按钮后,我想显示一个图像(使用图片框),等待几秒然后播放mp3声音,但我不能让它工作.我等了几秒钟System.Threading.Thread.Sleep(5000).问题是,图像总是出现在等待时间之后,但是我希望它首先显示,然后等待,然后播放mp3 ...我尝试使用WaitOnLoad = true但是它不起作用,不应该首先加载图像并继续阅读下一个代码行?
这是我尝试过的代码(不起作用):
private void button1_Click(object sender, EventArgs e) {
pictureBox1.WaitOnLoad = true;
pictureBox1.Load("image.jpg");
System.Threading.Thread.Sleep(5000);
MessageBox.Show("test");//just to test, here should be the code to play the mp3
}
Run Code Online (Sandbox Code Playgroud)
我还尝试使用"LoadAsync"加载图像并将代码放在等待并在"LoadCompleted"事件中播放mp3,但这不起作用......