按下按钮后,我想显示一个图像(使用图片框),等待几秒钟,然后播放 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
}
我还尝试使用“LoadAsync”加载图像并将代码等待并在“LoadCompleted”事件中播放 mp3,但这也不起作用......