亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? testpostexecute.cs

?? 線程池實例,1.1版本,用于代替.net自帶線程池
?? CS
字號:
using System;
using System.Threading;

using NUnit.Framework;

using Amib.Threading;

namespace SmartThreadPoolTests
{
	/// <summary>
	/// Summary description for DoTestPostExecute.
	/// </summary>
	[TestFixture]
	[Category("DoTestPostExecute")]
	public class TestPostExecution
	{
		/// <summary>
		/// 
		/// </summary>
		[Test]
		public void DefaultPostExecute_AlwaysCall()
		{
			Assert.IsTrue(DoTestDefaultPostExecute(CallToPostExecute.Always, true));
		}

		[Test]
		public void DefaultPostExecute_NeverCall()
		{
			Assert.IsTrue(DoTestDefaultPostExecute(CallToPostExecute.Never, false));
		}

		[Test]
		public void DefaultPostExecute_CallWhenCanceled()
		{
			Assert.IsTrue(DoTestDefaultPostExecute(CallToPostExecute.WhenWorkItemCanceled, false));
		}

		[Test]
		public void DefaultPostExecute_CallWhenNotCanceled()
		{
			Assert.IsTrue(DoTestDefaultPostExecute(CallToPostExecute.WhenWorkItemNotCanceled, true));
		}

		/// <summary>
		/// 
		/// </summary>
		[Test]
		public void PostExecute_AlwaysCall()
		{
			Assert.IsTrue(DoTestPostExecute(CallToPostExecute.Always, true));
		}

		[Test]
		public void PostExecute_NeverCall()
		{
			Assert.IsTrue(DoTestPostExecute(CallToPostExecute.Never, false));
		}

		[Test]
		public void PostExecute_CallWhenCanceled()
		{
			Assert.IsTrue(DoTestPostExecute(CallToPostExecute.WhenWorkItemCanceled, false));
		}

		[Test]
		public void PostExecute_CallWhenNotCanceled()
		{
			Assert.IsTrue(DoTestPostExecute(CallToPostExecute.WhenWorkItemNotCanceled, true));
		}

		/// <summary>
		/// 
		/// </summary>
		[Test]
		public void PostExecuteWithCancel_AlwaysCall()
		{
			Assert.IsTrue(DoTestPostExecuteWithCancel(CallToPostExecute.Always, true));
		}

		[Test]
		public void PostExecuteWithCancel_NeverCall()
		{
			Assert.IsTrue(DoTestPostExecuteWithCancel(CallToPostExecute.Never, false));
		}

		[Test]
		public void PostExecuteWithCancel_CallWhenCanceled()
		{
			Assert.IsTrue(DoTestPostExecuteWithCancel(CallToPostExecute.WhenWorkItemCanceled, true));
		}

		[Test]
		public void PostExecuteWithCancel_CallWhenNotCanceled()
		{
			Assert.IsTrue(DoTestPostExecuteWithCancel(CallToPostExecute.WhenWorkItemNotCanceled, false));
		}


		private class PostExecuteResult
		{
			public ManualResetEvent wh = new ManualResetEvent(false);
		}

		/// <summary>
		/// Example of how to use the post execute callback
		/// </summary>
		private bool DoTestDefaultPostExecute(CallToPostExecute callToPostExecute, bool answer)
		{ 
			STPStartInfo stpStartInfo = new STPStartInfo();
			stpStartInfo.CallToPostExecute = callToPostExecute;
			stpStartInfo.PostExecuteWorkItemCallback = new PostExecuteWorkItemCallback(this.DoSomePostExecuteWork);

			SmartThreadPool smartThreadPool = new SmartThreadPool(stpStartInfo);

			bool success = false;

			PostExecuteResult postExecuteResult = new PostExecuteResult();

			IWorkItemResult wir = 
				smartThreadPool.QueueWorkItem(
				new WorkItemCallback(this.DoSomeWork), 
				postExecuteResult);

			if (!wir.IsCompleted)
			{
				int result = (int)wir.GetResult();
				success = (1 == result);
				success = success && (postExecuteResult.wh.WaitOne(1000, true) == answer);
			}

			smartThreadPool.Shutdown();

			return success;
		}


		/// <summary>
		/// Example of how to use the post execute callback
		/// </summary>
		private bool DoTestPostExecute(CallToPostExecute callToPostExecute, bool answer)
		{ 
			SmartThreadPool smartThreadPool = new SmartThreadPool();

			bool success = false;

			PostExecuteResult postExecuteResult = new PostExecuteResult();

			IWorkItemResult wir = 
				smartThreadPool.QueueWorkItem(
				new WorkItemCallback(this.DoSomeWork), 
				postExecuteResult,
				new PostExecuteWorkItemCallback(this.DoSomePostExecuteWork),
				callToPostExecute);

			if (!wir.IsCompleted)
			{
				int result = (int)wir.GetResult();
				success = (1 == result);
				success = success && (postExecuteResult.wh.WaitOne(1000, true) == answer);
			}

			smartThreadPool.Shutdown();

			return success;
		}

		/// <summary>
		/// Example of how to queue a work item and then cancel it while it is in the queue.
		/// </summary>
		private bool DoTestPostExecuteWithCancel(CallToPostExecute callToPostExecute, bool answer) 
		{ 
			// Create a SmartThreadPool with only one thread.
			// It just to show how to use the work item canceling feature
			SmartThreadPool smartThreadPool = new SmartThreadPool(10*1000, 1);

			bool success = false;
			PostExecuteResult postExecuteResult = new PostExecuteResult();

			// Queue a work item that will occupy the thread in the pool
			smartThreadPool.QueueWorkItem(
				new WorkItemCallback(this.DoSomeWork), 
				null);

			// Queue another work item that will wait for the first to complete
			IWorkItemResult wir = 
				smartThreadPool.QueueWorkItem(
					new WorkItemCallback(this.DoSomeWork), 
					postExecuteResult,
					new PostExecuteWorkItemCallback(this.DoSomePostExecuteWork),
					callToPostExecute);


			// Wait a while for the thread pool to start executing the first work item
			Thread.Sleep(100);

			// Cancel the second work item while it still in the queue
			if (wir.Cancel())
			{
				success = (postExecuteResult.wh.WaitOne(1000, true) == answer);
			}

			smartThreadPool.Shutdown();

			return success;
		} 

		private object DoSomeWork(object state)
		{ 
			Thread.Sleep(1000);
			return 1;
		}

		private void DoSomePostExecuteWork(IWorkItemResult wir)
		{ 
			PostExecuteResult postExecuteResult = wir.State as PostExecuteResult;
			postExecuteResult.wh.Set();
		}

		private object SignalCancel(object state)
		{ 
			ManualResetEvent cancelWaitHandle = state as ManualResetEvent;
			Thread.Sleep(250);
			cancelWaitHandle.Set();
			return null;
		}
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美国产综合| 国产欧美一区视频| 国产99久久久国产精品| 亚洲国产精品久久人人爱| 久久久亚洲午夜电影| 欧美午夜电影一区| 成人精品国产免费网站| 美腿丝袜亚洲一区| 亚洲国产精品久久一线不卡| 国产清纯白嫩初高生在线观看91 | 韩国女主播成人在线| 国产精品久久久久久久蜜臀| 日韩精品在线看片z| 色婷婷av一区二区三区大白胸| 国产在线日韩欧美| 日本一区中文字幕| 亚洲一区二区三区四区在线免费观看 | 国产一区二区三区最好精华液| 一区二区三区久久| 中文字幕一区二区三区av| 26uuu国产在线精品一区二区| 欧美三级中文字幕| 色综合婷婷久久| 粉嫩一区二区三区在线看| 韩国精品一区二区| 狠狠色综合日日| 免费观看久久久4p| 视频精品一区二区| 三级久久三级久久| 亚州成人在线电影| 亚洲福利一区二区三区| 亚洲老妇xxxxxx| 亚洲日本va午夜在线影院| 国产精品成人网| 国产精品国产精品国产专区不片| 国产欧美日韩综合精品一区二区 | 亚洲黄色小视频| 最新成人av在线| 亚洲免费观看高清完整版在线观看 | 精品久久国产字幕高潮| 日韩一级二级三级| 91麻豆精品国产自产在线| 精品视频免费看| 欧美日韩国产一级片| 欧美日韩国产精选| 欧美高清精品3d| 欧美一三区三区四区免费在线看| 777xxx欧美| 久久综合99re88久久爱| 久久综合九色综合久久久精品综合 | bt7086福利一区国产| av不卡一区二区三区| 色吧成人激情小说| 欧美视频三区在线播放| 7777精品伊人久久久大香线蕉最新版| 777午夜精品视频在线播放| 欧美一级日韩免费不卡| 欧美成人一区二区三区在线观看| 欧美成人一区二区三区片免费 | 日韩午夜激情av| 精品av综合导航| 中文字幕av一区二区三区| 亚洲日本丝袜连裤袜办公室| 亚洲图片自拍偷拍| 狠狠色丁香久久婷婷综| 国产69精品久久久久毛片| 色综合久久久久久久久久久| 色一情一乱一乱一91av| 正在播放亚洲一区| 久久久久久夜精品精品免费| 中文字幕一区在线| 亚洲成av人片一区二区三区 | 国产精品91xxx| 91免费版在线看| 日韩欧美成人一区二区| 国产精品拍天天在线| 午夜精品123| 国产精品一区专区| 91高清视频免费看| 日韩午夜激情视频| 中文字幕日韩av资源站| 婷婷综合另类小说色区| 国产精品影视网| 欧美色老头old∨ideo| 精品福利视频一区二区三区| 亚洲女人****多毛耸耸8| 免费成人av在线| 99久久伊人久久99| 56国语精品自产拍在线观看| 国产日产欧产精品推荐色| 亚洲 欧美综合在线网络| 国产91丝袜在线播放0| 欧美日韩三级在线| 亚洲国产成人私人影院tom| 午夜一区二区三区在线观看| 国产a久久麻豆| 91麻豆精品国产91久久久久| 亚洲国产精品传媒在线观看| 男人操女人的视频在线观看欧美| 97精品电影院| 精品国产乱码久久久久久闺蜜 | 日本不卡在线视频| 99久久伊人精品| 久久久亚洲欧洲日产国码αv| 亚洲国产你懂的| av一区二区三区| 欧美sm美女调教| 午夜伊人狠狠久久| 色综合久久88色综合天天6| 精品国产百合女同互慰| 日韩欧美国产系列| 久久9热精品视频| 亚洲欧洲国产专区| 亚洲一区二区三区四区在线观看| 狠狠色丁香婷婷综合| 欧美日韩一区三区| 综合久久综合久久| 从欧美一区二区三区| www久久久久| 麻豆精品一区二区综合av| 欧美一a一片一级一片| 最新欧美精品一区二区三区| 国产精品正在播放| 日韩精品一区二区在线| 五月天网站亚洲| 欧美日韩国产在线播放网站| 亚洲美女视频一区| 91免费看视频| 亚洲欧美日韩国产综合| av电影天堂一区二区在线观看| 久久久久久久综合色一本| 国产麻豆精品在线| 久久久久久久久99精品| 精品一区二区三区在线播放视频| 91精品国产欧美一区二区| 日韩精品乱码免费| 日韩视频一区在线观看| 麻豆91精品91久久久的内涵| 精品福利视频一区二区三区| 美女视频第一区二区三区免费观看网站| 欧美区视频在线观看| 日韩国产欧美视频| 欧美videossexotv100| 国产精品系列在线观看| 国产日韩欧美a| 99久久99精品久久久久久| 亚洲欧洲99久久| 色狠狠桃花综合| 亚洲一二三四久久| 欧美福利一区二区| 亚洲二区视频在线| 欧美视频在线一区二区三区 | 日韩成人一级大片| 久久亚洲一区二区三区明星换脸 | 精品综合久久久久久8888| 亚洲精品在线三区| 成人动漫中文字幕| 一区二区三区在线视频免费 | 国产精品无码永久免费888| heyzo一本久久综合| 亚洲精品日日夜夜| 欧美日韩电影一区| 激情综合网天天干| 最近中文字幕一区二区三区| 欧美在线视频日韩| 美女网站色91| 国产精品国产a级| 欧美日韩午夜在线视频| 麻豆成人免费电影| 国产精品久久福利| 欧美日韩另类国产亚洲欧美一级| 久久国产综合精品| 中文字幕一区二区三区四区不卡 | 亚洲黄一区二区三区| 日韩欧美一区二区久久婷婷| 成人自拍视频在线观看| 一区二区三区不卡视频| 欧美一区二区三区成人| 成人激情视频网站| 日韩国产成人精品| 国产精品日日摸夜夜摸av| 精品视频999| 成人在线视频一区| 日韩电影网1区2区| 国产精品久久一卡二卡| 欧美精品久久一区| 99久久精品国产毛片| 青青草国产成人av片免费| 国产精品国产三级国产| 欧美成人女星排行榜| 色悠悠亚洲一区二区| 久久er99热精品一区二区| 亚洲色图一区二区| 久久你懂得1024| 激情成人综合网| 在线精品亚洲一区二区不卡| 欧美日韩免费电影| 久久精品人人做| 亚洲第一电影网| 国产一区二区看久久|