atsushieno / managed-midi

[Past project] Cross-platform MIDI processing library for mono and .NET (ALSA, CoreMIDI, Android, WinMM and UWP).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when closing inputPort: The specified device handle is invalid

eriveraa opened this issue · comments

Hi, i have this input port: (This is simplified code of my WPF Application):

private IMidiInput _TestInputPort;

var access = MidiAccessManager.Default;
_TestInputPort = access.OpenInputAsync("0").Result;
_TestInputPort.MessageReceived += Result_MessageReceived;

And when i close the the port with (on windows_closing):
_TestInputPort.CloseAsync()
I got the error:
System.ComponentModel.Win32Exception: 'The specified device handle is invalid. (5)'
You need to find WinmmMidiAccess.cs to view the source for the current call stack frame

Any ideas on how to fix it?
Thanks in advance.

I have no reproducible environment, now so as a quick check - did you try to close it twice e.g. calling CloseAsync() on already-Dispose()d objects?

Yes you are right, i was calling twice the closeAsync method. Thanks!