/// <summary> /// Releases unmanaged and - optionally - managed resources. /// Please not that this call is non-blocking/asynchronous. /// </summary> /// <param name="alsoManaged"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> private void Dispose(bool alsoManaged) { if (IsDisposed) { return; } // Run the close command immediately if (BeginSynchronousCommand() == false) { return; } // Dispose the wait handle: No more command accepted from this point forward. SynchronousCommandDone.Dispose(); try { var closeCommand = new CloseCommand(Commands); closeCommand.RunSynchronously(); } catch { throw; } finally { IsDisposed = true; } // Dispose the container Container?.Dispose(); Container = null; // Dispose the RTC Clock.Dispose(); // Dispose the Wait Event objects as they are // backed by unmanaged code PacketReadingCycle.Dispose(); FrameDecodingCycle.Dispose(); BlockRenderingCycle.Dispose(); SeekingDone.Dispose(); MediaChangingDone.Dispose(); }