atsushieno / managed-midi

[Past project] Cross-platform MIDI processing library for mono and .NET (ALSA, CoreMIDI, Android, WinMM and UWP).
MIT License
194 stars 26 forks source link

Error when closing inputPort: The specified device handle is invalid #44

Closed eriveraa closed 5 years ago

eriveraa commented 5 years ago

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.

atsushieno commented 5 years ago

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?

eriveraa commented 5 years ago

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