当前位置: 首页>>代码示例>>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;未经允许,请勿转载。