private void Run() { try { _VisualTarget = new VisualTarget(_HostVisual); _VisualTargetSource = new VisualTargetPresentationSource(_VisualTarget); lock (_Thread) { CreateMediaPlayer(); } _VisualTargetSource.RootVisual = _MediaElement; Dispatcher.Run(); } finally { if (_VisualTarget != null) { _VisualTarget.Dispose(); } lock (_Thread) { DestroyMediaPlayer(); } _CanPlay = false; } }
private void AnnimationWorkerThread(object arg) { var hostVisual = (HostVisual)arg; var visualTargetPs = new VisualTargetPresentationSource(hostVisual); SEvent.Set(); visualTargetPs.RootVisual = CreateElement(); System.Windows.Threading.Dispatcher.Run(); }
private void CreateAndShowContent() { Dispatcher = Dispatcher.CurrentDispatcher; VisualTargetPresentationSource source = new VisualTargetPresentationSource(HostVisual); _sync.Set(); source.RootVisual = _createContent(); DesiredSize = source.DesiredSize; _invalidateMeasure(); Dispatcher.Run(); source.Dispose(); }
private void MediaWorkerThread(object arg) { // Create the VisualTargetPresentationSource and then signal the // calling thread, so that it can continue without waiting for us. HostVisual hostVisual = (HostVisual)((object[])arg)[0]; VisualWrapper visualWrapper = (VisualWrapper)((object[])arg)[1]; VisualTargetPresentationSource visualTargetPS = new VisualTargetPresentationSource(hostVisual); s_event.Set(); // Create a MediaElement and use it as the root visual for the // VisualTarget. visualTargetPS.RootVisual = CreateMediaElement(visualWrapper); // Run a dispatcher for this worker thread. This is the central // processing loop for WPF. System.Windows.Threading.Dispatcher.Run(); }
private void CreateAndShowContent() { if (Dispatcher == null) { Dispatcher = Dispatcher.CurrentDispatcher; } VisualTargetPresentationSource source = new VisualTargetPresentationSource(HostVisual); _sync.Set(); _content = _createContent(); source.RootVisual = _content; _invalidateMeasure(); if (!_usingExternalDispatcher) { Dispatcher.Run(); } source.Dispose(); }
/// <summary> /// Medias the worker thread. /// </summary> /// <param name="arg">The arg.</param> private static void MediaWorkerThread(object arg) { try { var hostVisual = (HostVisual)arg; var visualTargetPS = new VisualTargetPresentationSource(hostVisual); _autoResetEvent.Set(); visualTargetPS.RootVisual = CreateMediaElement(); Dispatcher.Run(); } catch { } }