public void Dispose() { EventsHelper.CanRaiseEvent = false; CompositionTarget.Rendering -= CompositionTargetRendering; //Using Dispatcher.Invoke to force priority to ContextIdle Dispatcher.Invoke(DispatcherPriority.ContextIdle, new Action( delegate { FreeEvents(); if (IsPlaying) { Stop(); } AudioProperties.Dispose(); VideoProperties.Dispose(); LogProperties.Dispose(); AudioOutputDevices.Dispose(); Medias.Dispose(); VlcContext.InteropManager.MediaPlayerInterops.ReleaseInstance.Invoke(VlcContext.HandleManager.MediaPlayerHandles[this]); VlcContext.HandleManager.MediaPlayerHandles.Remove(this); myVideoLockCallbackHandle.Free(); myVideoUnlockCallbackHandle.Free(); myVideoSetFormatHandle.Free(); myVideoCleanupHandle.Free(); })); }