我用C#写了个windows应用程序,在某个事件发生的时候,声卡发声,同时主板也要发出beep音。但是在这两个声音同时响起后,应用程序就似乎死机了,没有反应,请教各位这是什么原因?

解决方案 »

  1.   

    beepSoundTimer_Tick是个timer控件,某个事件发生时,此timer控件的Enabled为true则播放Beep音。同时,PlaySound方法播放硬盘上的一个.wav文件。但是此时应用程序却死机了。[DllImport("winmm.dll", SetLastError=true)]
    public static extern bool PlaySound(string pszSound, IntPtr hmod, SoundFlags dwFlag);[DllImport("Kernel32.dll")]
    public static extern Boolean Beep(UInt32 frequency, UInt32 duration);private void beepSoundTimer_Tick(object sender, System.EventArgs e)
    {
        PInvoker.Beep(700,100);
        PInvoker.Beep(1700,100);
        PInvoker.Beep(700,100);
        PInvoker.Beep(1700,100);
        PInvoker.Beep(700,100);
        PInvoker.Beep(1700,100);
        PInvoker.Beep(700,100);
        PInvoker.Beep(1700,100);
        System.Threading.Thread.Sleep( 1000 );
    }