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


C# WaitCallback.BeginInvoke方法代码示例

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


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

示例1: Main

	static int Main ()
	{
		AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
		WaitCallback wcb = new WaitCallback ((a) => {
			throw new Exception ("From the threadpoool");
		});
		wcb.BeginInvoke (wcb, OnCBFinished, null);
		Thread.Sleep (1000);
		return 1;
	}
开发者ID:kumpera,项目名称:mono,代码行数:10,代码来源:threadpool-exceptions4.cs

示例2: Main

	static int Main ()
	{
		AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
		WaitCallback wcb = new WaitCallback ((a) => {
			Thread.CurrentThread.Abort ();
		});
		wcb.BeginInvoke (wcb, null, null);
		Thread.Sleep (1000);
		return 0;
	}
开发者ID:Zman0169,项目名称:mono,代码行数:10,代码来源:threadpool-exceptions6.cs

示例3: Main

	static int Main ()
	{
		monitor = new object ();
		AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
		WaitCallback wcb = new WaitCallback ((a) => {
			Thread.CurrentThread.Abort();
		});
		wcb.BeginInvoke (wcb, OnCBFinished, null);
		lock (monitor) {
			Monitor.Wait (monitor);
		}
		Thread.Sleep (1000);
		return 1;
	}
开发者ID:Zman0169,项目名称:mono,代码行数:14,代码来源:threadpool-exceptions5.cs

示例4: QueueUserWorkItem

		public static bool QueueUserWorkItem (WaitCallback callBack, object state)
		{
			if (callBack == null)
				throw new ArgumentNullException ("callBack");

			if (callBack.IsTransparentProxy ()) {
				IAsyncResult ar = callBack.BeginInvoke (state, null, null);
				if (ar == null)
					return false;
			} else {
				AsyncResult ares = new AsyncResult (callBack, state, true);
				pool_queue (ares);
			}
			return true;
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:15,代码来源:ThreadPool.cs

示例5: QueueUserWorkItem

		public static bool QueueUserWorkItem (WaitCallback callBack, object state)
		{
			if (callBack == null)
				throw new ArgumentNullException ("callBack");

#if MOONLIGHT
			callBack = MoonlightHandler (callBack);
#endif
			if (callBack.IsTransparentProxy ()) {
				IAsyncResult ar = callBack.BeginInvoke (state, null, null);
				if (ar == null)
					return false;
			} else {
				if (!callBack.HasSingleTarget)
					throw new Exception ("The delegate must have only one target");

				AsyncResult ares = new AsyncResult (callBack, state, true);
				pool_queue (ares);
			}
			return true;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:21,代码来源:ThreadPool.cs

示例6: UnsafeQueueUserWorkItem

		public static bool UnsafeQueueUserWorkItem (WaitCallback callBack, object state)
		{
			// no stack propagation here (that's why it's unsafe and requires extra security permissions)
			if (!callBack.IsTransparentProxy ()) {
				if (!callBack.HasSingleTarget)
					throw new Exception ("The delegate must have only one target");

				AsyncResult ares = new AsyncResult (callBack, state, false);
				pool_queue (ares);
				return true;
			}
			try {
				if (!ExecutionContext.IsFlowSuppressed ())
					ExecutionContext.SuppressFlow (); // on current thread only
				IAsyncResult ar = callBack.BeginInvoke (state, null, null);
				if (ar == null)
					return false;
			} finally {
				if (ExecutionContext.IsFlowSuppressed ())
					ExecutionContext.RestoreFlow ();
			}
			return true;
		}
开发者ID:carrie901,项目名称:mono,代码行数:23,代码来源:ThreadPool.cs

示例7: UnsafeQueueUserWorkItem

		public static bool UnsafeQueueUserWorkItem (WaitCallback callBack, object state)
		{
			if (Microsoft.ThreadPool.UseMicrosoftThreadPool) {
				return Microsoft.ThreadPool.UnsafeQueueUserWorkItem (callBack, state);
			} else {
				if (callBack == null)
					throw new ArgumentNullException ("callBack");

				// no stack propagation here (that's why it's unsafe and requires extra security permissions)
				if (!callBack.IsTransparentProxy ()) {
					AsyncResult ares = new AsyncResult (callBack, state, false);
					pool_queue (ares);
					return true;
				}
				try {
					if (!ExecutionContext.IsFlowSuppressed ())
						ExecutionContext.SuppressFlow (); // on current thread only
					IAsyncResult ar = callBack.BeginInvoke (state, null, null);
					if (ar == null)
						return false;
				} finally {
					if (ExecutionContext.IsFlowSuppressed ())
						ExecutionContext.RestoreFlow ();
				}
				return true;
			}
		}
开发者ID:psni,项目名称:mono,代码行数:27,代码来源:ThreadPool.cs

示例8: QueueUserWorkItem

		public static bool QueueUserWorkItem (WaitCallback callBack, object state)
		{
			if (Microsoft.ThreadPool.UseMicrosoftThreadPool) {
				return Microsoft.ThreadPool.QueueUserWorkItem (callBack, state);
			} else {
				if (callBack == null)
					throw new ArgumentNullException ("callBack");

				if (callBack.IsTransparentProxy ()) {
					IAsyncResult ar = callBack.BeginInvoke (state, null, null);
					if (ar == null)
						return false;
				} else {
					AsyncResult ares = new AsyncResult (callBack, state, !ExecutionContext.IsFlowSuppressed());
					pool_queue (ares);
				}
				return true;
			}
		}
开发者ID:psni,项目名称:mono,代码行数:19,代码来源:ThreadPool.cs

示例9: QueueUserWorkItem

		public static bool QueueUserWorkItem (WaitCallback callBack, object state)
		{
			if (callBack == null)
				throw new ArgumentNullException ("callBack");

#if NET_2_1 && !MONOTOUCH
			callBack = MoonlightHandler (callBack);
#endif
			IAsyncResult ar = callBack.BeginInvoke (state, null, null);
			if (ar == null)
				return false;
			return true;
		}
开发者ID:runefs,项目名称:Marvin,代码行数:13,代码来源:ThreadPool.cs

示例10: UnsafeQueueUserWorkItem

		public static bool UnsafeQueueUserWorkItem (WaitCallback callBack, object state)
		{
			// no stack propagation here (that's why it's unsafe and requires extra security permissions)
			IAsyncResult ar = null;
			try {
				if (!ExecutionContext.IsFlowSuppressed ())
					ExecutionContext.SuppressFlow (); // on current thread only

				ar = callBack.BeginInvoke (state, null, null);
			}
			finally {
				if (ExecutionContext.IsFlowSuppressed ())
					ExecutionContext.RestoreFlow ();
			}
			return (ar != null);
		}
开发者ID:runefs,项目名称:Marvin,代码行数:16,代码来源:ThreadPool.cs

示例11: OnBegin

 //异步页面的任务启动方法
 public IAsyncResult OnBegin(object sender, EventArgs e,
     AsyncCallback cb, object extraData)
 {
     _proc = new WaitCallback(ChatInvokeProc);
     Hashtable theUser = new Hashtable();
     theUser = (Hashtable)extraData;
     string user = theUser["guid"].ToString();
     _guid = user;
     Thread.CurrentThread.Name = "上下文线程" + user;
     //用户处理,不存在则增加,即为登录
     theUser["asyn"] = this;
     theUser["lastUpdateTime"] = DateTime.Now.ToString();
     Hashtable feachUser = new Hashtable();
     bool isInCach=false;
     for (var i = 0; i < globalCache.userCache.Count; i++)
     {
         feachUser = (Hashtable)globalCache.userCache[i];
         if (theUser["guid"].ToString() == feachUser["guid"].ToString())
         {
             globalCache.userCache[i] = theUser;
             isInCach = true;
         }
     }
     if (!isInCach)
     {
         globalCache.userCache.Add(theUser);
     }
     //开始异步执行,这里会开启一个新的辅助线程
     return _proc.BeginInvoke(extraData, cb, extraData);
 }
开发者ID:inlost,项目名称:moyo,代码行数:31,代码来源:Chat_Message.cs


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