gpt4 book ai didi

c# - 播放声音,等待它完成然后做点什么?

转载 作者:太空狗 更新时间:2023-10-30 00:13:33 26 4
gpt4 key购买 nike

我正在写一个 Windows Forms该应用程序应该播放三个声音文件,并在每个声音文件的末尾更改图像的来源。

我可以使用 System.Media.SoundPlayer 让它播放声音。但是,它似乎在另一个线程中播放声音,继续播放。

这样做的最终效果是只播放了最后的声音,所有的图像都发生了变化。

我已经尝试过 Thread.Sleep,但它会使整个 GUI 处于休眠状态,并且在休眠期过后,所有的事情都会立即发生,并且会播放最后一个声音。

更新

我以为 PlaySynch 可以正常工作,但它似乎卡住了我的 GUI,这不太理想。我还能做什么?

最佳答案

你试过了吗SoundPlayer.PlaySync Method ?来自帮助:

The PlaySync method uses the current thread to play a .wav file, preventing the thread from handling other messages until the load is complete.

关于c# - 播放声音,等待它完成然后做点什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/148676/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com