我正在开发一个 Silverlight 项目,以在网页上录制音频。
单击暂停按钮后,代码将始终抛出异常:
捕获源未停止
如果我在这行代码上放一个断点并在那里等待 3-5 秒然后运行代码,不会抛出异常。
if (audioSink.CaptureSource.State == CaptureState.Started) (break point is on this line)
这是代码
private void Pause(object sender, RoutedEventArgs e)
{
//System.Threading.Thread.Sleep(TimeSpan.FromSeconds(5));
if (audioSink.CaptureSource.State == CaptureState.Started)
{
audioSink.CaptureSource.Stop();
this.btnPause.IsEnabled = false;
this.btnRecord.IsEnabled = true;
this.btnSave.IsEnabled = true;
}
}
audioSink.CaptureSource.Stop(); (This is the line of code which throws the exception)