public override void Dispose() { try { VerifyAccess(); if (!IsDisposed) { if (_hostVisual != null && _connected) { RootVisual = null; // // Unregister this CompositionTarget from the MediaSystem. // // we need to properly unregister in a disconnected state MediaContext.UnregisterICompositionTarget(Dispatcher, this); } } } finally { base.Dispose(); } }
/// <summary> /// This function gets called when VisualTarget is created on the channel /// i.e. from CreateUCEResources. /// </summary> private void BeginHosting() { Debug.Assert(!_connected); try { // // Initiate hosting by the specified host visual. // _hostVisual.BeginHosting(this); _connected = true; } catch { // // If exception has occurred after we have registered with // MediaContext, we need to unregister to properly release // allocated resources. // NOTE: We need to properly unregister in a disconnected state // MediaContext.UnregisterICompositionTarget(Dispatcher, this); throw; } }