当前位置: 首页>>代码示例>>C#>>正文


C# SendOrPostCallback.Invoke方法代码示例

本文整理汇总了C#中SendOrPostCallback.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# SendOrPostCallback.Invoke方法的具体用法?C# SendOrPostCallback.Invoke怎么用?C# SendOrPostCallback.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SendOrPostCallback的用法示例。


在下文中一共展示了SendOrPostCallback.Invoke方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Send

 public override void Send(SendOrPostCallback d, object state)
 {
     SynchronizationContext oldContext = SynchronizationContext.Current;
     SynchronizationContext.SetSynchronizationContext(this);
     d.Invoke(state);
     SynchronizationContext.SetSynchronizationContext(oldContext);
 }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:7,代码来源:ThreadPoolSyncContext.cs

示例2: Post

 /// <summary>
 /// Dispatch a single job to the target thread and return immediately.
 /// This method can be called in background thread.
 /// </summary>
 /// <param name="callback">The callback which you wants to dispatch</param>
 public override void Post(SendOrPostCallback callback, object state)
 {
     jobs.Add(() =>
     {
         callback.Invoke(state);
     });
 }
开发者ID:pjc0247,项目名称:DISPATCHER,代码行数:12,代码来源:CustomSynchronizationContext.cs

示例3: Send

 public override void Send(SendOrPostCallback d, object state)
 {
     if (_thread == Thread.CurrentThread)
         d.Invoke(state);
     else
         throw new NotSupportedException("Synchronously sending from different threads is not supported.");
 }
开发者ID:ryanvs,项目名称:SingleThreadWorker,代码行数:7,代码来源:SingleThreadSynchronizationContext.cs

示例4: Post

 public override void Post(SendOrPostCallback d, object state)
 {
     synchronizationImplementation.Post(passedState =>
             {
                 SetSynchronizationContext(this);
                 cultureHolder.ApplyCulture();
                 d.Invoke(passedState);
             }, state);
 }
开发者ID:zaitsevyan,项目名称:Theseus,代码行数:9,代码来源:CultureAwareSynchronizationContext.cs

示例5: Post

                public override void Post(SendOrPostCallback callback, object state)
                {
                    Server.CallFuncEvent e = new Server.CallFuncEvent(() =>
                    {
                        callback.Invoke(state);
                    });

                    server.Enqueue(e);
                }
开发者ID:pjc0247,项目名称:Merona.cs,代码行数:9,代码来源:Server.Worker.SynchronizationContext.cs

示例6: Post

 public override void Post(SendOrPostCallback d, object state)
 {
     ThreadPool.QueueUserWorkItem(_ =>
     {
         SynchronizationContext oldContext = SynchronizationContext.Current;
         SynchronizationContext.SetSynchronizationContext(this);
         d.Invoke(state);
         SynchronizationContext.SetSynchronizationContext(oldContext);
     }, null);
 }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:10,代码来源:ThreadPoolSyncContext.cs

示例7: Send

		public override void Send (SendOrPostCallback d, object state)
		{
			if (Application.UIThread != null && Application.UIThread.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) {
				var evt = new ManualResetEventSlim (false);
				Exception exception = null;
				Application.Invoke (() => {
					try {
						d.Invoke (state);
					} catch (Exception ex) {
						exception = ex;
					} finally {
						Thread.MemoryBarrier ();
						evt.Set ();
					}
				});
				evt.Wait ();
				if (exception != null)
					throw exception;
			} else {
				d.Invoke (state);
			}
		}
开发者ID:m13253,项目名称:xwt,代码行数:22,代码来源:XwtSynchronizationContext.cs

示例8: Send

		public override void Send (SendOrPostCallback d, object state)
		{
			Exception ex = null;
			using (var waiter = new ManualResetEventSlim (false)) {
				Post (wrapper => {
					try {
						d.Invoke (state);
					} catch (Exception e) {
						ex = e;
					} finally {
						waiter.Set ();
					}
				}, null);
				waiter.Wait ();
			}

			if (ex != null)
				throw ex;
		}
开发者ID:alanmcgovern,项目名称:tunez,代码行数:19,代码来源:ConsoleSyncContext.cs

示例9: RunInSafeContext

		private void RunInSafeContext(SendOrPostCallback core)
		{
			if (UiSynchronizationContext != null)
			{
				UiSynchronizationContext.Send(core, null);
			}
			else
			{
				core.Invoke(null);
			}
		}
开发者ID:bbriggs,项目名称:wesay,代码行数:11,代码来源:DictionaryServiceProvider.cs

示例10: Send

        /// <summary>
        /// Dispatch a single job to the target thread and wait until the job ends.
        /// This method can be called in background thread.
        /// </summary>
        /// <param name="callback">The callback which you wants to dispatch</param>
        public override void Send(SendOrPostCallback callback, object state)
        {
            AutoResetEvent ev = new AutoResetEvent(false);
            jobs.Add(() =>
            {
                callback.Invoke(state);

                ev.Set();
            });

            ev.WaitOne();
        }
开发者ID:pjc0247,项目名称:DISPATCHER,代码行数:17,代码来源:CustomSynchronizationContext.cs

示例11: Post

 public override void Post(SendOrPostCallback d, object state)
 {
     d.Invoke(state);
 }
开发者ID:pzielinski86,项目名称:RuntimeTestCoverage,代码行数:4,代码来源:TestSyncContext.cs

示例12: Post

		public override void Post (SendOrPostCallback d, object state)
		{
			Application.Invoke (() => d.Invoke (state));
		}
开发者ID:m13253,项目名称:xwt,代码行数:4,代码来源:XwtSynchronizationContext.cs

示例13: Send

		public override void Send (SendOrPostCallback d, object state)
		{
			var evt = new ManualResetEventSlim (false);
			Exception exception = null;
			Post (s => {
				try {
					d.Invoke (state);
				} catch (Exception ex) {
					exception = ex;
				} finally {
					Thread.MemoryBarrier ();
					evt.Set ();
				}
			}, null);
			evt.Wait ();
			if (exception != null)
				throw exception;
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:18,代码来源:mdtool.cs

示例14: Post

 public override void Post(SendOrPostCallback d, object state)
 {
     _dispatcher.BeginInvoke(() => d.Invoke(state));
 }
开发者ID:bretternst,项目名称:brigand,代码行数:4,代码来源:DispatcherSynchronizationContext.cs


注:本文中的SendOrPostCallback.Invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。