Closed thebitbrine closed 2 years ago
I was using IInputDevice
instead of InputDevice
, consuming the class directly exposes .Dispose()
which solves the problem.
Final code:
//Init
IInputDevice _inputDevice = InputDevice.GetByName(deviceName);
_inputDevice.EventReceived += OnEventReceived;
_inputDevice.StartEventsListening();
//Dispose
_inputDevice.StopEventsListening();
_inputDevice.Dispose();
@thebitbrine Hmm, maybe it's a good idea to derive IInputDevice
from IDisposable
. I'll think about it.
Well, now IInputDevice
and IOutputDevice
are derived from IDisposable
. Changes are available in a prerelease version of the DryWetMIDI on NuGet – 6.1.2-prerelease3.
:rocket: 6.1.2 version is released now!
Prerelease NuGet packages will be unlisted soon, so please update the package references to the new version.
Thanks for using the library!
I opened the MIDI device using the following code:
Since there's no way to disconnect the device, I tried the following:
After switching to another MIDI input, now I want to connect to the first one but this is what I get:
Device is already in use (IN_OPENRESULT_ALLOCATED)
How can I Dispose/Disconnect the first device so I can connect to it later?