Esempio n. 1
0
		internal WorkThread(SyncContext syncContext)
		{
			this.syncContext = syncContext;

			this.thread = new Thread(this.Execute);
			this.thread.IsBackground = true;
			this.thread.Name = "#SyncPool";

			
		}
Esempio n. 2
0
		internal void CallBack(SyncContext syncContext, WorkThread workThread)
		{
			this.workThread = workThread;

			try
			{
				syncContext.IncrementCallbackCount();

				this.callback(state);
			}
			finally
			{
				syncContext.DecrementCallbackCount();

				// 任意一个工作项执行完后将 RunContext.Current、SecurityContext.Current 重设,确保后续工作项不误用前一工作项的相关上下文
				// 此处的调用与 IOCInstanceProvider.GetInstance 中的调用是成对的
				RunContext.ResetCurrent();
				SecurityContext.ResetCurrent();

				this.waitHandle.Set();
			}
		}