internal static MediaContext From(Dispatcher dispatcher)
        {
            MediaContext context = dispatcher._mediaContext;

            if (context == null)
            {
                Type type = typeof(GlobalLock);
                lock (type)
                {
                    context = dispatcher._mediaContext;
                    if (context == null)
                    {
                        context = new MediaContext();
                        dispatcher._mediaContext = context;
                    }
                }
            }
            return(context);
        }
        /// <summary>
        /// Gets the MediaContext from the context passed in as argument.
        /// </summary>
        internal static MediaContext From(Dispatcher dispatcher)
        {
            Debug.Assert(dispatcher != null, "Dispatcher required");

            var cm = dispatcher._mediaContext;

            if (cm == null)
            {
                lock (typeof(GlobalLock)) {
                    cm = dispatcher._mediaContext;

                    if (cm == null)
                    {
                        cm = new MediaContext();
                        dispatcher._mediaContext = cm;
                    }
                }
            }

            return(cm);
        }
        internal void BeginInvokeOnRender(DispatcherOperationCallback callback, object arg)
        {
            if (this._invokeOnRenderCallbacks == null)
            {
                MediaContext context = this;
                lock (context)
                {
                    if (this._invokeOnRenderCallbacks == null)
                    {
                        this._invokeOnRenderCallbacks = new ArrayList();
                    }
                }
            }
            ArrayList list = this._invokeOnRenderCallbacks;

            lock (list)
            {
                this._invokeOnRenderCallbacks.Add(new InvokeOnRenderCallback(callback, arg));
            }
            this.PostRender();
        }