• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# WaitOrTimerCallback类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中WaitOrTimerCallback的典型用法代码示例。如果您正苦于以下问题:C# WaitOrTimerCallback类的具体用法?C# WaitOrTimerCallback怎么用?C# WaitOrTimerCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WaitOrTimerCallback类属于命名空间,在下文中一共展示了WaitOrTimerCallback类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: RegisteredWaitHandle

		internal RegisteredWaitHandle (WaitHandle waitObject, WaitOrTimerCallback callback, 
												 object cbState, int timeout, bool executeOnlyOnce)
		{
			this.waitObject = waitObject;
			this.callback = callback;
			this.cbState = cbState;
			this.timeout = timeout;
         this.executeOnlyOnce = executeOnlyOnce;

			StWaitable waitable;
			if ((waitable = waitObject.waitable) == null) {

				/*
				 * Either we're dealing with a disposed wait handle
				 * or with some other derived class.
				 */
 
				UnparkCallback (StParkStatus.Inflated);
				return;
			}

			cbparker = new CbParker (UnparkCallback, false, true);
			int ignored = 0;
         waitBlock = waitable._WaitAnyPrologue (cbparker, StParkStatus.Success, ref hint, ref ignored);

			state = ACTIVE;
         int ws = cbparker.EnableCallback (timeout);
         if (ws != StParkStatus.Pending) {
				UnparkCallback (ws);
	      }
		}
开发者ID:duarten,项目名称:mono,代码行数:31,代码来源:RegisteredWaitHandle.cs


示例2: OverlappedContext

        public OverlappedContext()
        {
            if (OverlappedContext.completeCallback == null)
            {
                OverlappedContext.completeCallback = Fx.ThunkCallback(new IOCompletionCallback(CompleteCallback));
            }
            if (OverlappedContext.eventCallback == null)
            {
                OverlappedContext.eventCallback = Fx.ThunkCallback(new WaitOrTimerCallback(EventCallback));
            }
            if (OverlappedContext.cleanupCallback == null)
            {
                OverlappedContext.cleanupCallback = Fx.ThunkCallback(new WaitOrTimerCallback(CleanupCallback));
            }

            this.bufferHolder = new object[] { OverlappedContext.dummyBuffer };
            this.overlapped = new Overlapped();
            this.nativeOverlapped = this.overlapped.UnsafePack(OverlappedContext.completeCallback, this.bufferHolder);

            // When replacing the buffer, we need to provoke the CLR to fix up the handle of the pin.
            this.pinnedHandle = GCHandle.FromIntPtr(*((IntPtr*)nativeOverlapped +
                (IntPtr.Size == 4 ? HandleOffsetFromOverlapped32 : HandleOffsetFromOverlapped64)));
            this.pinnedTarget = this.pinnedHandle.Target;

            // Create the permanently rooted holder and put it in the Overlapped.
            this.rootedHolder = new RootedHolder();
            this.overlapped.AsyncResult = rootedHolder;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:28,代码来源:OverlappedContext.cs


示例3: SafeTimer

 public SafeTimer()
 {
     WaitFlag = false;
     timeout = 0;
     WOTcb = new WaitOrTimerCallback(HandleTimer);
     OpenSource.Utilities.InstanceTracker.Add(this);
 }
开发者ID:Tieske,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:7,代码来源:SafeTimer.cs


示例4: _ThreadPoolWaitOrTimerCallback

 internal _ThreadPoolWaitOrTimerCallback(WaitOrTimerCallback waitOrTimerCallback, object state, bool compressStack, ref StackCrawlMark stackMark)
 {
     this._waitOrTimerCallback = waitOrTimerCallback;
     this._state = state;
     if (compressStack && !ExecutionContext.IsFlowSuppressed())
     {
         this._executionContext = ExecutionContext.Capture(ref stackMark, ExecutionContext.CaptureOptions.OptimizeDefaultCase | ExecutionContext.CaptureOptions.IgnoreSyncCtx);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:_ThreadPoolWaitOrTimerCallback.cs


示例5: _ThreadPoolWaitOrTimerCallback

 internal _ThreadPoolWaitOrTimerCallback(WaitOrTimerCallback waitOrTimerCallback, object state, bool compressStack, ref StackCrawlMark stackMark)
 {
     this._waitOrTimerCallback = waitOrTimerCallback;
     this._state = state;
     if (compressStack && !ExecutionContext.IsFlowSuppressed())
     {
         this._executionContext = ExecutionContext.Capture(ref stackMark);
         ExecutionContext.ClearSyncContext(this._executionContext);
     }
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:10,代码来源:_ThreadPoolWaitOrTimerCallback.cs


示例6: InitializeConnectionTimeoutHandler

 private static void InitializeConnectionTimeoutHandler()
 {
     _socketTimeoutDelegate = new WaitOrTimerCallback(TimeoutConnections);
     _socketTimeoutWaitHandle = new AutoResetEvent(false);
     _registeredWaitHandle = 
         ThreadPool.UnsafeRegisterWaitForSingleObject(
             _socketTimeoutWaitHandle, 
             _socketTimeoutDelegate, 
             "IpcConnectionTimeout", 
             _socketTimeoutPollTime, 
             true); // execute only once
 } // InitializeSocketTimeoutHandler
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:12,代码来源:PortCache.cs


示例7: RegisteredWaitHandle

		internal RegisteredWaitHandle (WaitHandle waitObject, WaitOrTimerCallback callback, object state, TimeSpan timeout, bool executeOnlyOnce)
		{
			_waitObject = waitObject;
			_callback = callback;
			_state = state;
			_timeout = timeout;
			_executeOnlyOnce = executeOnlyOnce;
			_finalEvent = null;
			_cancelEvent = new ManualResetEvent (false);
			_callsInProcess = 0;
			_unregistered = false;
		}
开发者ID:carrie901,项目名称:mono,代码行数:12,代码来源:RegisteredWaitHandle.cs


示例8: Page_Load

	/**
	 * we lay the groundwork for further async calls in page load
 	 */
	public void Page_Load( Object sender, EventArgs e )
	{
		Response.Write("page load entered\n");

		// we set the timeout to something really long, so that .net
		// won't time out our request - we want long running
		TimeSpan timeOut = new TimeSpan( 1, 0, 0, 0, 0 );
		this.AsyncTimeout = timeOut;
		
		// fire up a delegate that invokes the function that we 
		// ultimately want to call
		m_doAsyncDelegate = new DoAsyncDelegate( DoAsync );
		
		// this is a hack to get some browsers to display something
		// we write some data to fill the buffer or something	
		for( int i=0; i < 1000; i++ )
		{ 
			Response.Write("<span></span>");
		}
		Response.Flush();

		// here we set up a periodic poller using threadpool. the
		// basic idea is that we have a call back that is periodically
		// visited by a threadpool thread.  This really isn't a poll,
		// and is not really done by the threadpool, we use an autoresetevent
		m_wtCallback = new WaitOrTimerCallback( Callback );
		AutoResetEvent are = new AutoResetEvent( false );
		ThreadPool.RegisterWaitForSingleObject( are, m_wtCallback, null, 1000, false );
	
		// the meat of getting this all to work revolves around the 
		// registration of handlers for begin and end
		RegisterAsyncTask( 
			new PageAsyncTask(
	   		new BeginEventHandler( this.BeginLoad ),
	  		new EndEventHandler( this.EndLoad ),
	  		null, null, false )
		);

	}
开发者ID:modulexcite,项目名称:Comet-server-for-ASP.NET,代码行数:42,代码来源:async-threadpool.aspx.cs


示例9: OverlappedContext

 public unsafe OverlappedContext()
 {
     if (completeCallback == null)
     {
         completeCallback = Fx.ThunkCallback(new IOCompletionCallback(OverlappedContext.CompleteCallback));
     }
     if (eventCallback == null)
     {
         eventCallback = Fx.ThunkCallback(new WaitOrTimerCallback(OverlappedContext.EventCallback));
     }
     if (cleanupCallback == null)
     {
         cleanupCallback = Fx.ThunkCallback(new WaitOrTimerCallback(OverlappedContext.CleanupCallback));
     }
     this.bufferHolder = new object[] { dummyBuffer };
     this.overlapped = new Overlapped();
     this.nativeOverlapped = this.overlapped.UnsafePack(completeCallback, this.bufferHolder);
     this.pinnedHandle = GCHandle.FromIntPtr(*((IntPtr*) (this.nativeOverlapped + (((IntPtr.Size == 4) ? -4 : -3) * sizeof(IntPtr)))));
     this.pinnedTarget = this.pinnedHandle.Target;
     this.rootedHolder = new RootedHolder();
     this.overlapped.AsyncResult = this.rootedHolder;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:22,代码来源:OverlappedContext.cs


示例10: RegisterWaitForSingleObject

        public static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, long millisecondsTimeOutInterval, bool executeOnlyOnce)
        {
            if (executeOnlyOnce != true)
            {
                throw new NotSupportedException("executeOnlyOnce must be true");
            }

            int tickTime = (int)Math.Min(100, millisecondsTimeOutInterval);

            int totalTimeElapsed = 0;
            Timer timer = null;

            timer = new Timer((s) =>
            {
                // Timer will fire every due period...if total time exceeds millisecondsTimeoutInterval then we call the timeoutcallback
                // otherwise we wait...if at any point the waitObject is signaled...than we can abort.
                if (waitObject.WaitOne(0))
                {
                    // Signal is set so no timeout occured
                    timer.Dispose();
                    return;
                }
                else if (totalTimeElapsed > millisecondsTimeOutInterval)
                {
                    // Timeout has occured
                    timer.Dispose();
                    callBack(state, true);
                }
                else
                {
                    totalTimeElapsed += tickTime;
                }
            }, null, tickTime, tickTime);

            return null;
        }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:36,代码来源:ThreadPool.cs


示例11:

	public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject
				(WaitHandle waitObject, WaitOrTimerCallback callBack,
				 Object state, TimeSpan timeout,
				 bool executeOnlyOnce)
			{
				return RegisterWaitForSingleObject
					(waitObject, callBack, state,
					 Monitor.TimeSpanToMS(timeout), executeOnlyOnce);
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:9,代码来源:ThreadPool.cs


示例12: AddMyObjectChanged

        internal static void AddMyObjectChanged(EventHandler<ObjectChangedEventArgs> callback,
                                        ref EventHandler<ObjectChangedEventArgs> objectChanged,
                                        object lockObjChangedEvent,
                                        ref RegisteredWaitHandle regObjChangedWaitHandle,
                                        ref AutoResetEvent objChangedEvent,
                                        ref SafeCollabEvent safeObjChangedEvent,
                                        WaitOrTimerCallback ObjectChangedCallback)
        {
            //
            // Register a wait handle if one has not been registered already
            //
            lock (lockObjChangedEvent){
                if (objectChanged == null){

                    objChangedEvent = new AutoResetEvent(false);

                    //
                    // Register callback with a wait handle
                    //

                    regObjChangedWaitHandle = ThreadPool.RegisterWaitForSingleObject(objChangedEvent, //Event that triggers the callback
                                            ObjectChangedCallback, //callback to be called 
                                            null, //state to be passed
                                            -1,   //Timeout - aplicable only for timers
                                            false //call us everytime the event is set
                                            );

                    PEER_COLLAB_EVENT_REGISTRATION pcer = new PEER_COLLAB_EVENT_REGISTRATION();
                    pcer.eventType = PeerCollabEventType.MyObjectChanged;
                    pcer.pInstance = IntPtr.Zero;


                    //
                    // Register event with collab
                    //

                    int errorCode = UnsafeCollabNativeMethods.PeerCollabRegisterEvent(
                                                                        objChangedEvent.SafeWaitHandle,
                                                                        1,
                                                                        ref pcer,
                                                                        out safeObjChangedEvent);
                    if (errorCode != 0){
                        Logging.P2PTraceSource.TraceEvent(TraceEventType.Error, 0, "PeerCollabRegisterEvent returned with errorcode {0}", errorCode);
                        throw PeerToPeerException.CreateFromHr(SR.GetString(SR.Collab_ObjectChangedRegFailed), errorCode);
                    }
                }
                objectChanged += callback;
            }

            Logging.P2PTraceSource.TraceEvent(TraceEventType.Information, 0, "AddObjectChanged() successful.");

        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:52,代码来源:CollaborationHelperFunctions.cs


示例13: UnsafeRegisterWaitForSingleObject

		public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (WaitHandle waitObject,
			WaitOrTimerCallback callBack, object state, uint millisecondsTimeOutInterval,
			bool executeOnlyOnce) 
		{
			throw new NotImplementedException ();
		}
开发者ID:carrie901,项目名称:mono,代码行数:6,代码来源:ThreadPool.cs


示例14: RegisterWaitForSingleObject

		public static RegisteredWaitHandle RegisterWaitForSingleObject (WaitHandle waitObject,
										WaitOrTimerCallback callBack,
										object state,
										uint millisecondsTimeOutInterval,
										bool executeOnlyOnce)
		{
			return RegisterWaitForSingleObject (waitObject, callBack, state,
							    (long) millisecondsTimeOutInterval, executeOnlyOnce);
		}
开发者ID:carrie901,项目名称:mono,代码行数:9,代码来源:ThreadPool.cs


示例15: StartExitCallbackIfNeeded

		void StartExitCallbackIfNeeded ()
		{
			lock (thisLock) {
				bool start = (exitWaitHandle == null && enableRaisingEvents && exited_event != null);
				if (start && process_handle != IntPtr.Zero) {
					WaitOrTimerCallback cb = new WaitOrTimerCallback (CBOnExit);
					ProcessWaitHandle h = new ProcessWaitHandle (process_handle);
					exitWaitHandle = ThreadPool.RegisterWaitForSingleObject (h, cb, this, -1, true);
				}
			}
		}
开发者ID:chriswebb,项目名称:mono,代码行数:11,代码来源:Process.cs


示例16: SafeTimer_SINGLE

 public SafeTimer_SINGLE()
 {
     WOTcb = new WaitOrTimerCallback(HandleTimer);
 }
开发者ID:genielabs,项目名称:intel-upnp-dlna,代码行数:4,代码来源:SafeTimer_SINGLE.cs


示例17: SetAsyncEventSelect

        private bool SetAsyncEventSelect(AsyncEventBits blockEventBits)
        {
            GlobalLog.Enter("Socket#" + ValidationHelper.HashString(this) + "::SetAsyncEventSelect", "blockEventBits:" + blockEventBits.ToString() + " m_BlockEventBits:" + m_BlockEventBits.ToString() + " willBlockInternal:" + willBlockInternal.ToString());
            GlobalLog.Assert(blockEventBits != AsyncEventBits.FdNone, "Socket#{0}::SetAsyncEventSelect|Use UnsetAsyncEventSelect for FdNone.", ValidationHelper.HashString(this));
            GlobalLog.Assert(m_BlockEventBits == AsyncEventBits.FdNone || m_BlockEventBits == blockEventBits, "Socket#{0}::SetAsyncEventSelect|Can't change from one active wait to another.", ValidationHelper.HashString(this));
            GlobalLog.Assert(m_RegisteredWait == null, "Socket#{0}::SetAsyncEventSelect|Already actively waiting on an op.", ValidationHelper.HashString(this));

            // This check is bogus, too late diggin into a historical reason for it.
            // Make sure the upper level will fail with ObjectDisposedException
            if (m_RegisteredWait != null)
                return false;

            //
            // This will put us into non-blocking mode.  Create the event if it isn't, and register a wait.
            //
            if (m_AsyncEvent == null)
            {
                Interlocked.CompareExchange<ManualResetEvent>(ref m_AsyncEvent, new ManualResetEvent(false), null);
                if (s_RegisteredWaitCallback == null)
                    s_RegisteredWaitCallback = new WaitOrTimerCallback(RegisteredWaitCallback);
            }

            //
            // Try to win over Dispose is there is a ----
            //
            if (Interlocked.CompareExchange(ref m_IntCleanedUp, 2, 0) != 0)
            {
                GlobalLog.Leave("Socket#" + ValidationHelper.HashString(this) + "::SetAsyncEventSelect() Already Cleaned up, returning ... ", string.Empty);
                return false;
            }

            try
            {
                m_BlockEventBits = blockEventBits;
                m_RegisteredWait = ThreadPool.UnsafeRegisterWaitForSingleObject(m_AsyncEvent, s_RegisteredWaitCallback, this, Timeout.Infinite, true);
            }
            finally
            {
                //
                // Release dispose if any is waiting
                //
                Interlocked.Exchange(ref m_IntCleanedUp, 0);
            }

            SocketError errorCode = SocketError.NotSocket;
            //
            // issue the native call
            //
            try {
                errorCode = UnsafeNclNativeMethods.OSSOCK.WSAEventSelect(m_Handle, m_AsyncEvent.SafeWaitHandle, blockEventBits);
            }
            catch (Exception e)
            {
                if (NclUtilities.IsFatal(e))
                    throw;
                GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::SetAsyncEventSelect() !!! (converting to ObjectDisposed) Exception :" + e.ToString());
                GlobalLog.Assert(CleanedUp, "Socket#{0}::SetAsyncEventSelect|WSAEventSelect got exception and CleanedUp not set.", ValidationHelper.HashString(this));
            }

            if (errorCode==SocketError.SocketError) {
                //
                // update our internal state after this socket error
                // we won't throw since this is an internal method
                //
                UpdateStatusAfterSocketError(errorCode);
            }

            //
            // the call to WSAEventSelect will put us in non-blocking mode, 
            // hence we need update internal status
            //
            willBlockInternal = false;

            GlobalLog.Leave("Socket#" + ValidationHelper.HashString(this) + "::SetAsyncEventSelect", "m_BlockEventBits:" + m_BlockEventBits.ToString() + " willBlockInternal:" + willBlockInternal.ToString());
            return errorCode == SocketError.Success;
        }
开发者ID:REALTOBIZ,项目名称:mono,代码行数:76,代码来源:Socket.cs


示例18: ArgumentNullException

	// Register a callback to be invoked when a wait handle is available.
	public static RegisteredWaitHandle RegisterWaitForSingleObject
				(WaitHandle waitObject, WaitOrTimerCallback callBack,
				 Object state, int millisecondsTimeOutInterval,
				 bool executeOnlyOnce)
			{
				if(waitObject == null)
				{
					throw new ArgumentNullException("waitObject");
				}
				if(millisecondsTimeOutInterval < -1)
				{
					throw new ArgumentOutOfRangeException
						("millisecondsTimeOutInterval",
						 _("ArgRange_NonNegOrNegOne"));
				}
				WorkItem item = new WorkItem(ClrSecurity.GetPermissionsFrom(1),
											 waitObject, callBack, state,
											 millisecondsTimeOutInterval,
											 executeOnlyOnce);
				AddWorkItem(item);
				return new RegisteredWaitHandle(item);
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:23,代码来源:ThreadPool.cs


示例19: UnsafeRegisterWaitForSingleObject

		public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (WaitHandle waitObject,
			WaitOrTimerCallback callBack, object state, uint millisecondsTimeOutInterval,
			bool executeOnlyOnce) 
		{
			if (Microsoft.ThreadPool.UseMicrosoftThreadPool)
				return Microsoft.ThreadPool.UnsafeRegisterWaitForSingleObject (waitObject, callBack, state, millisecondsTimeOutInterval, executeOnlyOnce);
			else
				throw new NotImplementedException ();
		}
开发者ID:psni,项目名称:mono,代码行数:9,代码来源:ThreadPool.cs


示例20: RegisterWaitForSingleObject

		public static RegisteredWaitHandle RegisterWaitForSingleObject (WaitHandle waitObject,
										WaitOrTimerCallback callBack,
										object state,
										uint millisecondsTimeOutInterval,
										bool executeOnlyOnce)
		{
			if (Microsoft.ThreadPool.UseMicrosoftThreadPool)
				return Microsoft.ThreadPool.RegisterWaitForSingleObject (waitObject, callBack, state, millisecondsTimeOutInterval, executeOnlyOnce);
			else
				return RegisterWaitForSingleObject (waitObject, callBack, state, (long) millisecondsTimeOutInterval, executeOnlyOnce);
		}
开发者ID:psni,项目名称:mono,代码行数:11,代码来源:ThreadPool.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Waiter类代码示例发布时间:2022-05-24
下一篇:
C# WaitDialogForm类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap