當前位置: 首頁>>代碼示例>>C#>>正文


C# Threading.DispatcherOperation類代碼示例

本文整理匯總了C#中System.Windows.Threading.DispatcherOperation的典型用法代碼示例。如果您正苦於以下問題:C# DispatcherOperation類的具體用法?C# DispatcherOperation怎麽用?C# DispatcherOperation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DispatcherOperation類屬於System.Windows.Threading命名空間,在下文中一共展示了DispatcherOperation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BeginUpdateLayout

 public void BeginUpdateLayout()
 {
     if (updateLayoutOperation == null || updateLayoutOperation.Status == DispatcherOperationStatus.Completed)
     {
         updateLayoutOperation = Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, (Action)UpdateLayout);
     }
 }
開發者ID:highzion,項目名稱:Granular,代碼行數:7,代碼來源:LayoutManager.cs

示例2: InvokeParametersTest

        public void InvokeParametersTest()
        {
            int value = 0;

            DispatcherOperation operation0 = new DispatcherOperation(() => value = 1);
            operation0.Invoke();
            Assert.AreEqual(1, value);
        }
開發者ID:highzion,項目名稱:Granular,代碼行數:8,代碼來源:DispatcherOperationTest.cs

示例3: Cancel

 /// <summary>
 ///     Cancels a pending DispatcherOperation
 /// </summary>
 internal void Cancel()
 {
     if (IsPending)
     {
         _operation.Abort();
     }
     _operation = null;
 }
開發者ID:Cireson,項目名稱:EntityFramework6,代碼行數:11,代碼來源:DeferredRequest.cs

示例4: Cancel

 internal void Cancel()
 {
     if (_operation != null)
     {
         Debug.Assert(_operation.Status == DispatcherOperationStatus.Pending);
         _operation.Abort();
         _operation = null;
     }
 }
開發者ID:Cireson,項目名稱:EntityFramework6,代碼行數:9,代碼來源:DeferredRequest.cs

示例5: Request

        internal void Request(object arg)
        {
            if (_operation == null)
            {
                Debug.Assert(_callback != null);

                _operation =
                    Dispatcher.CurrentDispatcher.BeginInvoke(
                        DispatcherPriority.Loaded,
                        new DispatcherOperationCallback(DispatcherOperation), arg);
            }
        }
開發者ID:Cireson,項目名稱:EntityFramework6,代碼行數:12,代碼來源:DeferredRequest.cs

示例6: Request

        /// <summary>
        ///     Requests that a new DispatcherOperation be placed on the Dispatcher queue
        /// </summary>
        /// <param name="arg">The object to send the callback in its arg parameter.</param>
        internal void Request(object arg)
        {
            if (_operation != null)
            {
                Cancel();
            }

            _operation = Dispatcher.CurrentDispatcher.BeginInvoke(
                DispatcherPriority.Background,
                new DispatcherOperationCallback(DispatcherOperation),
                arg);
        }
開發者ID:Cireson,項目名稱:EntityFramework6,代碼行數:16,代碼來源:DeferredRequest.cs

示例7: OnRendering

        /// <summary>
        /// Called when [rendering].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void OnRendering(object sender, EventArgs e)
        {
            if (this.isDirty)
            {
                if (this.LowPriorityRendering)
                {
                    // if we called render previously...
                    if (this.previousRenderCall != null)
                    {
                        var previousStatus = this.previousRenderCall.Status;

                        // ... and the operation didn't finish yet - then skip the current call
                        if (previousStatus == System.Windows.Threading.DispatcherOperationStatus.Pending
                            || previousStatus == System.Windows.Threading.DispatcherOperationStatus.Executing)
                        {
                            return;
                        }
                    }

                    this.previousRenderCall = this.Dispatcher.BeginInvoke(this.renderDelegate, System.Windows.Threading.DispatcherPriority.Input);
                }
                else
                {
                    this.renderDelegate();
                }

                this.IsDirty = this.AutoRender;
            }
        }
開發者ID:vmsr42,項目名稱:AncientHorror,代碼行數:34,代碼來源:WaveCanvas.cs

示例8: OnRendering

        /// <summary>
        /// Handles the <see cref="CompositionTarget.Rendering"/> event.
        /// </summary>
        /// <param name="sender">The sender is in fact a the UI <see cref="Dispatcher"/>.</param>
        /// <param name="e">Is in fact <see cref="RenderingEventArgs"/>.</param>
        private void OnRendering(object sender, EventArgs e)
        {
            if (!renderTimer.IsRunning)
                return;

            // Check if there is a deferred updateAndRenderOperation in progress.
            if (updateAndRenderOperation != null)
            {
                // If the deferred updateAndRenderOperation has not yet ended...
                var status = updateAndRenderOperation.Status;
                if (status == DispatcherOperationStatus.Pending ||
                    status == DispatcherOperationStatus.Executing)
                {
                    // ... return immediately.
                    return;
                }

                updateAndRenderOperation = null;

                // Ensure that at least every other cycle is done at DispatcherPriority.Render.
                // Uncomment if animation stutters, but no need as far as I can see.
                // this.lastRenderingDuration = TimeSpan.Zero;
            }

            // If rendering took too long last time...
            if (lastRenderingDuration > MaxRenderingDuration)
            {
                // ... enqueue an updateAndRenderAction at DispatcherPriority.Input.
                updateAndRenderOperation = Dispatcher.BeginInvoke(
                    updateAndRenderAction, DispatcherPriority.Input);
            }
            else
            {
                UpdateAndRender();
            }
        }
開發者ID:chantsunman,項目名稱:helix-toolkit,代碼行數:41,代碼來源:DPFCanvas.cs

示例9: BeginInvoke

		public DispatcherOperation BeginInvoke (Delegate d, params object[] args)
		{
			DispatcherOperation op = null;
			lock (queuedOperations) {
				op = new DispatcherOperation (d, args);
				queuedOperations.Enqueue (op);
				if (!pending) {
					if (callback == null)
						callback = new TickCallHandler (dispatcher_callback);
					NativeMethods.time_manager_add_dispatcher_call (NativeMethods.surface_get_time_manager (Deployment.Current.Surface.Native),
					                                                   callback, IntPtr.Zero);
					pending = true;
				}
			}
			return op;
		}
開發者ID:kangaroo,項目名稱:moon,代碼行數:16,代碼來源:Dispatcher.cs

示例10: DispatcherOperationProxy

 /// <summary>
 /// Initializes a new instance of the <see cref="DispatcherOperationProxy"/> class.
 /// </summary>
 /// <param name="operation">The operation.</param>
 public DispatcherOperationProxy(DispatcherOperation operation)
 {
     _operation = operation;
 }
開發者ID:ssethi,項目名稱:TestFrameworks,代碼行數:8,代碼來源:DispatcherOperationProxy.cs

示例11: DispatcherOperationEvent

            public DispatcherOperationEvent(DispatcherOperation op, TimeSpan timeout)
            {
                _operation = op;
                _timeout = timeout;
                _event = new ManualResetEvent(false);
                _eventClosed = false;
                
                lock(DispatcherLock)
                {
                    // We will set our event once the operation is completed or aborted.
                    _operation.Aborted += new EventHandler(OnCompletedOrAborted);
                    _operation.Completed += new EventHandler(OnCompletedOrAborted);

                    // Since some other thread is dispatching this operation, it could
                    // have been dispatched while we were setting up the handlers.
                    // We check the state again and set the event ourselves if this
                    // happened.
                    if(_operation._status != DispatcherOperationStatus.Pending && _operation._status != DispatcherOperationStatus.Executing)
                    {
                        _event.Set();
                    }
                }
            }
開發者ID:JianwenSun,項目名稱:cc,代碼行數:23,代碼來源:DispatcherOperation.cs

示例12: Initialize

 public abstract void Initialize(DispatcherOperation operation);
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:1,代碼來源:DispatcherOperationTaskSource.cs

示例13: Enqueue

        public void Enqueue(object userState)
        {
            if (userState == null)
                throw new ArgumentNullException("userState");

            CurrentContext = userState as BackgroundActionContext;
            if (CurrentContext == null)
                throw new NotSupportedException("Not support non BackgroundActionContext type userState");

            _latestOperation = UIDispatcher.BeginInvoke(() => DoWork(userState), DispatcherPriority.Background);
        }
開發者ID:Mrding,項目名稱:Ribbon,代碼行數:11,代碼來源:UIThreadTask.cs

示例14: TestDispatcherOpOnThread

		public void TestDispatcherOpOnThread ()
		{
			Thread t = new Thread (new ThreadStart (thread));
			Dispatcher d = Dispatcher.CurrentDispatcher;
			
			t.Start ();
			op = Dispatcher.CurrentDispatcher.BeginInvoke (DispatcherPriority.Normal, (Action) delegate {
				Console.WriteLine ("Some methods");
			});
			wait.Set ();
			wait2.WaitOne ();
		}
開發者ID:nobled,項目名稱:mono,代碼行數:12,代碼來源:DispatcherTest.cs

示例15: DPFCanvas

 /// <summary>
 /// 
 /// </summary>
 public DPFCanvas()
 {
     updateAndRenderAction = UpdateAndRender;
     updateAndRenderOperation = null;
     renderTimer = new Stopwatch();
     MaxRenderingDuration = TimeSpan.FromMilliseconds(20.0);
     Loaded += OnLoaded;
     Unloaded += OnUnloaded;
     ClearColor = global::SharpDX.Color.Gray;
     IsShadowMapEnabled = false;
     IsMSAAEnabled = true;
 }
開發者ID:chantsunman,項目名稱:helix-toolkit,代碼行數:15,代碼來源:DPFCanvas.cs


注:本文中的System.Windows.Threading.DispatcherOperation類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。