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


C# Threading.RegisteredWaitHandle类代码示例

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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


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