微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

访问冲突调用 WaveInEvent.StopRecording()

如何解决访问冲突调用 WaveInEvent.StopRecording()

我正在尝试使用 Zak's code 定期从麦克风获取几秒钟信息并将每个录音写入不同的文件。我将它放在 VS2017 中的 Windows.Form C# 应用程序中,使用 .NET 框架 4.7.2。我使用了当前的 Nuget 包 NAudio 2.0.0
经过一些明显的工作时间后,可能是几个小时后,应用程序崩溃并出现访问冲突异常。请注意,即使是 try/catch 块也无法捕获异常,这是由 Windows 事件寄存器捕获的:

Applicazione: TestAudioAcquisitionForms.exe
Versione framework: v4.0.30319
Descrizione: il processo è stato terminato a causa di un'eccezione non gestita.
Informazioni sull'eccezione: System.AccessViolationException
in NAudio.Wave.WaveInterop.waveInReset(IntPtr)
in NAudio.Wave.WaveInEvent.StopRecording()
in Recorder_ns.NAudio.Recorder.TimerElapsed(System.Object,System.Timers.ElapsedEventArgs)
in System.Timers.Timer.MyTimerCallback(System.Object)
in System.Threading.TimerQueueTimer.CallCallbackInContext(System.Object)
in System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Object,Boolean)
in System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,Boolean)
in System.Threading.TimerQueueTimer.CallCallback()
in System.Threading.TimerQueueTimer.Fire()
in System.Threading.TimerQueue.FireNextTimers()
in System.Threading.TimerQueue.AppDomainTimerCallback(Int32)

欢迎任何帮助。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。