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

C# Threading.RegisteredWaitHandle类代码示例

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

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



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

示例1: CallbackInfo

 public CallbackInfo(Action<RawBusMessage, Exception> callback, Type replyType, ManualResetEvent ev, RegisteredWaitHandle handle)
 {
     _callback = callback;
     _replyType = replyType;
     _ev = ev;
     _handle = handle;
 }
开发者ID:parshim,项目名称:MessageBus,代码行数:7,代码来源:RpcConsumer.cs


示例2: CheckAsync

        /// <summary>
        /// 
        /// </summary>
        /// <param name="nextCheckSeconds">check again after X seconds</param>
        /// <param name="containerName">what container to sync</param>
        public static void CheckAsync(int nextCheckSeconds, string containerName, string rootPath)
        {
            lock (typeof(QuickDeployService)) {
                
                // clear existing handle if already exists
                if (RegisteredWaitHandle != null)
                    RegisteredWaitHandle.Unregister(null);

                var waitHandle = new AutoResetEvent(false);
                RegisteredWaitHandle = ThreadPool.RegisterWaitForSingleObject(
                    waitHandle,
                    // Method to execute
                    (state, timeout) => {
                        WhenTimeComes(containerName, rootPath);
                    },
                    // optional state object to pass to the method
                    null,
                    // Execute the method after 5 seconds
                    TimeSpan.FromSeconds(nextCheckSeconds),
                    // Set this to false to execute it repeatedly every 5 seconds
                    false
                );
            }
        }
开发者ID:bogdan-litescu,项目名称:OpenTraits.QuickDeployService,代码行数:29,代码来源:QuickDeployService.cs


示例3: SetTimer

		public void SetTimer(int MillisecondTimeout, TimeElapsedHandler CB)
		{
			lock(TimeoutList)
			{
				long Ticks = DateTime.Now.AddMilliseconds(MillisecondTimeout).Ticks;
				while(TimeoutList.ContainsKey(Ticks)==true)
				{
					++Ticks;
				}

				TimeoutList.Add(Ticks,CB);
				if(TimeoutList.Count==1)
				{
					// First Entry
					mre.Reset();
					handle = ThreadPool.RegisterWaitForSingleObject(
						mre,
						WOTcb,
						null,
						MillisecondTimeout,
						true);
				}
				else
				{
					mre.Set();
				}
			}
		}
开发者ID:Scannow,项目名称:SWYH,代码行数:28,代码来源:SafeTimer_SINGLE.cs


示例4: HeartbeatSender

        public HeartbeatSender(TimeSpan period, RestTarget heartbeatRest)
        {
            _period = period;
            _heartbeatRest = heartbeatRest;

            _registeredWaitHandle = ThreadPool.RegisterWaitForSingleObject(_disposeEvent, SendHeartBeats, null, _period, false);
        }
开发者ID:BietteMaxime,项目名称:OG-DotNet,代码行数:7,代码来源:HeartbeatSender.cs


示例5: unregister

        public bool unregister()
        {
            ManualResetEvent callbackThreadComplete = new ManualResetEvent(false);
            int timeToWait = 5000; //milliseconds
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            if (this.sessionRegisteredWait != null)
            {
                if (this.sessionRegisteredWait.Unregister(callbackThreadComplete))
                {
                    Console.WriteLine("waiting on succesful unregister");
                    callbackThreadComplete.WaitOne(timeToWait);
                }
            }
            this.sessionRegisteredWait = null;

            long elapsed = sw.ElapsedMilliseconds;
            Console.WriteLine("Elapsed: {0} millisec", elapsed);
            if (elapsed >= timeToWait)
            {
                Console.WriteLine("Error. Callback was not signaled");
                return false;
            }
            else
            {
                Console.WriteLine("Success");
                return true;
            }
            

            

        }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:33,代码来源:regression_749068.cs


示例6: BufferRecorder

        /// <summary>
        /// create a buffer recorder for a stream
        /// </summary>
        /// <param name="number">ordinal for diagnostics</param>
        /// <param name="streamID">the stream I'm for</param>
        public BufferRecorder( int number, int streamID )
        {
            isAvailable = true;

            this.number =  number;

            indices = new Index[Constants.IndexCapacity];
            currentIndex = 0;

            buffer = new byte[Constants.BufferSize];
            this.streamID = streamID;

            // setup the db writer thread
            canSave = new AutoResetEvent(false);
            // The BufferTimeout feature is "turned off" so that the buffer won't automatically write to disk sporadically.
            //  This is a nice safety feature we should try to turn back on.  It was turned off because it was saving data
            //  and causing frames to be written out of order in the DB.
            waitHandle = ThreadPool.RegisterWaitForSingleObject( canSave,
                new WaitOrTimerCallback(InitiateSave),
                this,
                Constants.BufferTimeout,
                false);

            Thread.Sleep(50); // Allows for the Registration to occur & get setup
            // Without the Sleep, if we walk into a massive session with lots of data moving, we get slammed & can't keep up.
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:31,代码来源:BufferRecorder.cs


示例7: BufferPlayer

        /// <summary>
        /// set ourselves up, we are pretty dumb so need to be told who we're sending for
        /// and where to get our data from, and when to start sending..
        /// </summary>
        /// <remarks>
        /// It seems that we don't use maxFrameSize any more.  hmm.  Remove it?
        /// </remarks>
        public BufferPlayer(int streamID, int maxFrameSize, int maxFrameCount, int maxBufferSize)
        {
            Debug.Assert( maxBufferSize >= maxFrameSize ); // just for kicks...

            buffer = new BufferChunk( maxBufferSize );
            indices = new Index[maxFrameCount+1]; // Pri3: why is this "+1" here? (DO NOT REMOVE YET)

            this.populating = false;
            this.streamOutOfData = false;
            this.streamID = streamID;

            this.currentIndex = 0;
            this.indexCount = 0;
            this.startingTick = 0;

            canPopulate = new AutoResetEvent(false);

            // pool a thread to re-populate ourselves
            waitHandle = ThreadPool.RegisterWaitForSingleObject(
                canPopulate,
                new WaitOrTimerCallback( InitiatePopulation ),
                this,
                -1, // never timeout to perform a population
                false );
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:32,代码来源:BufferPlayer.cs


示例8: BeginRunOnTimer

 private void BeginRunOnTimer(object state, bool isTimeout)
 {
     //Wait for this race condition to satisfy
     while (m_registeredHandle == null)
         ;
     m_registeredHandle.Unregister(null);
     m_registeredHandle = null;
     OnRunning();
 }
开发者ID:rmc00,项目名称:gsf,代码行数:9,代码来源:ThreadContainerThreadpool.cs


示例9: QueueLogWriter

        private volatile int flushIsRunning = 0; // 0 = false, 1 = true

        #endregion Fields

        #region Constructors

        public QueueLogWriter()
        {
            File.Delete(aof);

            fileStream = new FileStream(aof, FileMode.OpenOrCreate, FileAccess.Write);

            flushSignalWaitHandle
                = ThreadPool.RegisterWaitForSingleObject(flushSignal, (state, timedOut) => Flush(), null, -1, false);
            flushSignal.Set(); // signal to start pump right away
        }
开发者ID:jdaigle,项目名称:LightRail,代码行数:16,代码来源:QueueLogWriter.cs


示例10: EventsQueue

 public EventsQueue(Boolean bufferedOutput, Int32 autoFlushPeriod, 
     Action<IEnumerable<EventRecord>> flushAction)
 {
     this.bufferedOutput = bufferedOutput;
     this.flushAction = flushAction;
     this.syncObject = new Object();
     this.eventsList = new List<EventRecord>();
     this.flushEvent = new AutoResetEvent(false);
     this.registeredWaitHandle = ThreadPool.RegisterWaitForSingleObject(
         this.flushEvent, FlushEventSignaledCallback, null, autoFlushPeriod * 1000, false);
 }
开发者ID:Dennis-Petrov,项目名称:Cash,代码行数:11,代码来源:EventsQueue.cs


示例11: RegisterTimeout

        public void RegisterTimeout(TimeSpan interval, Action callback)
        {
            lock (m_syncRoot)
            {
                if (m_callback != null)
                    throw new Exception("Duplicate calls are not permitted");

                m_callback = callback;
                m_resetEvent = new ManualResetEvent(false);
                m_registeredHandle = ThreadPool.RegisterWaitForSingleObject(m_resetEvent, BeginRun, null, interval, true);
            }
        }
开发者ID:GridProtectionAlliance,项目名称:openHistorian,代码行数:12,代码来源:TimeoutOperation.cs


示例12: 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


示例13: CancelAsyncOperation

 public unsafe void CancelAsyncOperation()
 {
     this.rootedHolder.ThisHolder = null;
     if (this.registration != null)
     {
         this.registration.Unregister(null);
         this.registration = null;
     }
     this.bufferPtr = null;
     this.bufferHolder[0] = dummyBuffer;
     this.pendingCallback = null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:OverlappedContext.cs


示例14: TimeoutSockets

 private static void TimeoutSockets(object state, bool wasSignalled)
 {
     DateTime utcNow = DateTime.UtcNow;
     lock (_connections)
     {
         foreach (DictionaryEntry entry in _connections)
         {
             ((RemoteConnection) entry.Value).TimeoutSockets(utcNow);
         }
     }
     _registeredWaitHandle.Unregister(null);
     _registeredWaitHandle = ThreadPool.UnsafeRegisterWaitForSingleObject(_socketTimeoutWaitHandle, _socketTimeoutDelegate, "TcpChannelSocketTimeout", _socketTimeoutPollTime, true);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:SocketCache.cs


示例15: Log

 static Log() {
   _useDiagnostic = System.Diagnostics.Debugger.IsAttached;
   try { int window_height = Console.WindowHeight; _useConsole = true; }
   catch { _useConsole = false; }
   if(!Directory.Exists("../log")) {
     Directory.CreateDirectory("../log");
   }
   useFile = true;
   _lfMask = "../log/{0}_" + Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location) + ".log";
   _records = new System.Collections.Concurrent.ConcurrentQueue<LogRecord>();
   _kickEv = new AutoResetEvent(false);
   _wh = ThreadPool.RegisterWaitForSingleObject(_kickEv, Process, null, -1, false);
 }
开发者ID:Wassili-Hense,项目名称:Host.V04f,代码行数:13,代码来源:Log.cs


示例16: Cancel

 public void Cancel()
 {
     lock (m_syncRoot)
     {
         if (m_registeredHandle != null)
         {
             m_registeredHandle.Unregister(null);
             m_resetEvent.Dispose();
             m_resetEvent = null;
             m_registeredHandle = null;
             m_callback = null;
         }
     }
 }
开发者ID:GridProtectionAlliance,项目名称:openHistorian,代码行数:14,代码来源:TimeoutOperation.cs


示例17: BeginRun

 private void BeginRun(object state, bool isTimeout)
 {
     lock (m_syncRoot)
     {
         if (m_registeredHandle == null)
             return;
         m_registeredHandle.Unregister(null);
         m_resetEvent.Dispose();
         m_callback();
         m_resetEvent = null;
         m_registeredHandle = null;
         m_callback = null;
     }
 }
开发者ID:GridProtectionAlliance,项目名称:openHistorian,代码行数:14,代码来源:TimeoutOperation.cs


示例18: register

        public void register()
        {


            this.sessionNotification = new ManualResetEvent(false);
      
            this.sessionRegisteredWait = ThreadPool.RegisterWaitForSingleObject(
                                                            this.sessionNotification,
                                                            ServiceCallbackOnPositionAvailable,
                                                            this,   /* object state */
                                                            -1,     /* INFINITE */
                                                            true    /* ExecuteOnlyOnce */);


        }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:15,代码来源:regression_749068.cs


示例19: Begin

        private void Begin(Func<AsyncCallback, object, IAsyncResult> beginMethod, AsyncCallback callback, object state, TimeSpan timeout)
        {
            this.asyncResult = beginMethod(callback, state);

#if WINDOWS_PHONE
            WaitHandle asyncWaitHandle = this.fakeEvent;
#else
            WaitHandle asyncWaitHandle = this.asyncResult.AsyncWaitHandle;
#endif

            this.waitHandle = ThreadPool.RegisterWaitForSingleObject(asyncWaitHandle, this.WaitCallback, state, timeout, true);
            if (this.disposed)
            {
                this.UnregisterWaitHandle();
            }
        }
开发者ID:kenegozi,项目名称:azure-sdk-for-net,代码行数:16,代码来源:APMWithTimeout.cs


示例20: ConnectionCache

        public ConnectionCache(int keepAlive, ConnectionFactory connectionFactory)
        {
            // parameters validation
            if (connectionFactory == null)
                throw new ArgumentNullException("connectionFactory");
            if (keepAlive < 1)
                throw new ArgumentOutOfRangeException("keepAlive");

            _connectionFactory = connectionFactory;
            _keepAlive = TimeSpan.FromSeconds(keepAlive);

            // Schedule timeout method
            _timeoutDelegate = OnTimerElapsed;
            _timeoutWaitHandle = new AutoResetEvent(false);
            _registeredTimeoutWaitHandle = ThreadPool.RegisterWaitForSingleObject(
                _timeoutWaitHandle, _timeoutDelegate, null, _keepAlive, true);
        }
开发者ID:vadimskipin,项目名称:DVRemoting,代码行数:17,代码来源:ConnectionCache.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Threading.Semaphore类代码示例发布时间:2022-05-26
下一篇:
C# Threading.ReaderWriterLockSlim类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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