2014-10-16 112 views
0

我在Visual C#中有20 ms間隔的計時器。在背景中播放聲音

public class Global 
    { 
     //Global Vars 
     public static System.Media.SoundPlayer sound = new System.Media.SoundPlayer(Project.Properties.Resources.tock); 
    } 

    private void timer1_Tick(object sender, EventArgs e) 
    { 
     Global.sound.PlaySync(); 
    } 

My tock.wav播放70毫秒。我的問題是,timer1_tick正在等待,直到聲音播放,我不想短我的wav文件。有沒有任何選項可以在後臺播放聲音?這聽起來可能不好,但我會試一試。

回答

1

要在單獨的線程中啓動SoundPlayer,只需撥打Play()而不是PlaySync()即可。

查看the documentation僅供參考。