コード例 #1
0
ファイル: Scheduler.cs プロジェクト: tosos/Geewhiz
 private static int Comparison(TimerMessage a, TimerMessage b)
 {
     if (a.nextTime < b.nextTime) {
         return -1;
     } else if (a.nextTime > b.nextTime) {
         return 1;
     } else {
         return 0;
     }
 }
コード例 #2
0
ファイル: Scheduler.cs プロジェクト: tosos/Geewhiz
 public static void AddSchedule(float time, string message, bool repeat, GameObject obj = null)
 {
     TimerMessage msg = new TimerMessage ();
     msg.message = message;
     msg.nextTime = Time.time + time;
     msg.secondsBetween = (repeat ? time : 0.0f);
     msg.gameObject = obj;
     instance.priorityQueue.Add (msg);
     instance.enabled = true;
 }
 private void HandleTimerMessage(TimerMessage message)
 {
     _timer.Interval = message.Span;
     if (_timer.IsEnabled && message.StopTimer)
     {
         _timer.Stop();
     }
     if (!_timer.IsEnabled && message.StartTimer)
     {
         _timer.Start();
     }
 }
コード例 #4
0
        private async Task RunAsync()
        {
            while (true)
            {
                var message = new TimerMessage
                {
                    Label     = _messageLabel,
                    Timestamp = DateTime.UtcNow
                };

                _client.Publish(message);

                await Task.Delay(_interval);
            }
        }
コード例 #5
0
 private void NestTimerRefresh(TimerMessage o)
 {
     NestService.ColumnsSync(new NestSync(), (Action<NestSync>)(r => this.NestUpdate(r)), this.TwitterAccountID);
 }
コード例 #6
0
ファイル: MessageThread.cs プロジェクト: Comostoad/isx
        /************************************************************************************/
        /// <summary>
        /// Retrieves a message from the queue.
        /// </summary>
        /// <remarks>
        /// This function will throw an exception if called from outside the context of the owner thread.
        /// </remarks>
        /// <param name="bWaitForMessageIfEmpty"></param>
        /// <returns>Returns NULL if no message was in the queue.</returns>
        protected ThreadMessage GetMessage(bool bWaitForMessageIfEmpty)
        {
            int iWaitObjectIndex = -1;

            if (bWaitForMessageIfEmpty)
            {
                iWaitObjectIndex = WaitHandle.WaitAny(m_aWaitHandles);                 // TODO: Should we figure a way to abort this?
            }
            else
            {
                iWaitObjectIndex = WaitHandle.WaitAny(m_aWaitHandles, 0, false);
            }

            WaitHandle ThisSignalledHandle = null;

            if (iWaitObjectIndex != WaitHandle.WaitTimeout)
            {
                ThisSignalledHandle = m_aWaitHandles[iWaitObjectIndex];
            }

            /// If a wait was signalled and it wasn't the standard queue filled event, return it.
            /// The recipient has an obligation to clear the signal or unregister the handle,
            /// otherwise the next call to GetMessage will return the same handle.
            if (ThisSignalledHandle != null && ThisSignalledHandle.SafeWaitHandle != m_QueueFilledEvent.SafeWaitHandle)
            {
                return(new WaitHandleSignalledMessage(ThisSignalledHandle));
            }

            ThreadMessage NewIncomingMessage = null;

            lock (m_Lock)
            {
                // Dummy check.
                if (m_Thread.ManagedThreadId != Thread.CurrentThread.ManagedThreadId)
                {
                    throw new Exception("TekMessageThread.GetMessage can only be called from the context of the owner thread.");
                }

                /// Check for any legit messages.
                if (m_MessageQueue.Count > 0)
                {
                    NewIncomingMessage = m_MessageQueue.Dequeue();
                }

                /// Check our timer list and generate a pseudo-message.
                /// Timers have lowest priority just like Win32 because if the messages build
                /// up and if the message handler takes time to process (such as connection timeout),
                /// then the backlog of messages will drown out any other processing.
                else if (m_PulsedTimers.Count > 0)
                {
                    int iTimerID = m_PulsedTimers[0];
                    m_PulsedTimers.Remove(iTimerID);

                    TimerDesc ThisTimerDesc = m_Timers[iTimerID];
                    NewIncomingMessage = new TimerMessage(iTimerID, ThisTimerDesc.m_Context, ThisTimerDesc.m_Timer.Interval);
                }

                /// Now that there is NOTHING to retrieve, make the event block again.
                if (QueuedMessageCount == 0)
                {
                    m_QueueFilledEvent.Reset();
                }
            }

            return(NewIncomingMessage);
        }
コード例 #7
0
 private void RequestRefresh(TimerMessage o)
 {
   this.Refresh();
 }
コード例 #8
0
ファイル: Page1View.xaml.cs プロジェクト: ladimolnar/Samples
 private void OnTimerMessage(TimerMessage timerMessage)
 {
     logger.LogInfo("Page1View: OnTimerMessage: {0}.", timerMessage);
 }
コード例 #9
0
 private void RestRefresh(TimerMessage o)
 {
     this.CheckRefreshTimer();
     this.TwitViewModel.RefreshCommand.Execute((object)null);
 }
コード例 #10
0
ファイル: Page2View.xaml.cs プロジェクト: ladimolnar/Samples
 private void OnTimerMessage(TimerMessage timerMessage)
 {
     logger.LogInfo("Page2View: OnTimerMessage: {0}.", timerMessage);
 }
コード例 #11
0
 private Task Handle(TimerMessage m)
 {
     return((_pattern != null) ? _pattern.OnTimer() : Task.CompletedTask);
 }