public static void onTimerHandler(object sender, EventArgs e) { NetSceneDownloadVoice voice = TimerEventArgs.getObject(e) as NetSceneDownloadVoice; if (voice == null) { Log.e("NetSceneDownloadVoice", "onTimerHandler, invalid timer args"); } else if (voice.mVoiceContext == null) { Log.d("NetSceneDownloadVoice", "scene.mVoiceContext is null,doScene already finished"); } else if (voice.mVoiceContext.isBlockRunning()) { Log.d("NetSceneDownloadVoice", "doScene recving msg block now status=" + voice.mVoiceContext.mStatus); } else { Log.i("NetSceneDownloadVoice", "doScene start download msg block now status=" + voice.mVoiceContext.mStatus); MsgTrans currentVoiceBlock = voice.mVoiceContext.GetCurrentVoiceBlock(); if (currentVoiceBlock == null) { if (voice.mTimerObject.FireCount > 300) { Log.e("NetSceneDownloadVoice", "the block timer reached the max times = " + 300); voice.doSceneFinished(5); voice.cancel(); } } else { voice.doSceneBlock(currentVoiceBlock); } } }
/// <summary> /// Event: Occurs when the timer is fired. /// </summary> /// <param name="o"></param> /// <param name="e"></param> private void pollTimer_TimerFired(object o, TimerEventArgs e) { this.IgnoreSubDirectories = false; pollTimer.StopTimer(); //Console.WriteLine("Number of rules: {0}", Rules.Length); foreach (Rule r in Rules) { //TODO: Work on exclusion list. TaskItemList list = r["HASHAFTER"]; foreach (TaskItem taskitem in list) { lock (Poll) { //Console.WriteLine("RuleName={0}; RuleValues:{1}", r.Name, r.wildcards.Value); if (!CompletedDirs.Contains(taskitem.Name.ToLower()) && !Poll.Contains(taskitem.Name.ToLower()) && !Exclude(taskitem.Name)) { ManualResetEvent mre = new ManualResetEvent(false); tmpEvents.Add(mre); Task task = new Task(taskitem, wildcards, SearchBrain.List.MaxPerFolder, mre); task.MaxDepth = taskitem.MaxDepth; Poll.Add(task); } } } } }
/// <summary> /// Handles the timer tick. /// </summary> /// <param name="timerId">The timer id.</param> protected internal virtual void HandleTimerTick(int timerId) { switch (timerId) { case mouseTimer: { window.StopTimer(mouseTimer); if (!window.Dragged) { mouseIgnore = true; if (manager.StoneMenu != null) { manager.StoneMenu.PopupAtCursor(); } } break; } default: TimerEventArgs eventArgs = new TimerEventArgs(timerId); try { OnTimerTick(eventArgs); } finally { eventArgs.Dispose(); } break; } }
/// <summary> /// Event: occurs when the timer is fired. /// </summary> /// <param name="o"></param> /// <param name="e"></param> private void OnTimerFired(object o, TimerEventArgs e) { if (TimerFired != null) { TimerFired(o, e); } }
private void OnTimerComplete(object sender, TimerEventArgs e) { // Should save the pomodoro session to some sort of // data persistance SavePomodoroSessionAsync(); }
public void OnTimerStateChanged(object sender, TimerEventArgs e) { switch (Pomodoro.State) { case TimerServiceState.Stopped: CommandLabel = "Start"; break; case TimerServiceState.Running: CommandLabel = "Pause"; break; case TimerServiceState.Paused: CommandLabel = "Resume"; break; default: break; } Display = Pomodoro.TimeString(); Progress = Pomodoro.Progress; ((JFCommand)CancelTimerCommand).RaiseCanExecuteChanged(); }
public override void Show_EventArgs(object sender, TimerEventArgs e) { Console.ResetColor(); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine(e.Message + " " + e.Seconds + " seconds"); }
private void Timer_Tick(TimerEventArgs e) { foreach (VisibleSurfaceBase surface in VisibleSurfaces._surfaces) { surface.RenderBackbuffer(false); } }
private void Timer_Elapsed(object sender, TimerEventArgs e) { foreach (var reader in this.Readers) { this.OnReduce(reader); } }
protected void Animate(object sender, TimerEventArgs e) { Time += e.Interval * AnimSpeed; if (Sheets[FCurrentSheet].Animated == false) { return; } if (Time >= Sheets[FCurrentSheet].FrameIntervals[FCurrentFrame]) { // Preparing for frame switch FCurrentFrame++; if (FCurrentFrame == Sheets[FCurrentSheet].FrameCount) { Time -= Sheets[FCurrentSheet].FrameIntervals[FCurrentFrame - 1]; CurrentFrame = 0; } else // Performing frame switch { CurrentFrame = FCurrentFrame; } } }
public void StopDash(object sender, TimerEventArgs e) { if (rb) { rb.velocity = beforeDash; } }
public void CounterChanged(object sender, TimerEventArgs e) { Invoke(new Action(() => { lbTime.Text = Services.Timer.FormatTime(e.Count); })); }
// Method that will be subscribed to event and will be executed each time this event is raised public static void DisplayTime(object sender, TimerEventArgs e) { int cursorX = Console.CursorLeft; int cursorY = Console.CursorTop; Console.SetCursorPosition(1, 1); Console.WriteLine(sender.ToString(), e.TimerTime); Console.SetCursorPosition(cursorX, cursorY); }
private static ICountDownNotifier[] GetNotifiers( TimerEventArgs timerA, TimerEventArgs timerB, TimerEventArgs timerC) { return(new ICountDownNotifier[] { new MethodProcessor(timerA, SayStart, SayEnd), new DelegateProcessor(timerB, SayStart, SayEnd), new LambdaProcessor(timerC, SayStart, SayEnd) }); }
public virtual void Update(object sender, TimerEventArgs e) { Time += e.Interval; foreach (IUpdatable upd in Updatables) { upd.Update(e.Interval); } }
public void SecondCallback(object sender, TimerEventArgs eventArgs) { TestContext.WriteLine("SecondCallback"); TestContext.WriteLine($"Sender: {sender}"); TestContext.WriteLine($"DateTime: {eventArgs.DateTime}"); TestContext.WriteLine($"Message: {eventArgs.Message}"); isSecondCallbackRun = true; }
public void OnTick(object sender, TimerEventArgs args) { global::System.EventHandler handler = this.Updating; if (handler != null) { handler(sender, global::System.EventArgs.Empty); } }
public void OnTimerInterruptedEvent(object sender, TimerEventArgs e) { handleTimerCompletedEvent(sender, e); if (m_SelectedRowForRecord != null) { RecordingInterruptedEvent(this, new WiimoteRecordingEventArgs(e, m_SelectedRowForRecord, m_RecordingInvoker)); m_SelectedRowForRecord = null; } }
protected override void OnTimerTick(TimerEventArgs e) { base.OnTimerTick(e); if (e.TimerId == DelayTimer) { StopTimer(DelayTimer); StartFade(300); } }
public void OnTick(TimerEventArgs args) { global::System.EventHandler <TimerEventArgs> handler = this._tick; if (handler != null) { handler(null, args); } }
// Internal helper method that checks to see if any // objects are subscribed to the event. If any are, // their event handler method will be called through // the multicast delegate. private void RaiseTimerAlarm() { if (OnTimerAlarm != null) { Console.WriteLine(); TimerEventArgs t = new TimerEventArgs(); OnTimerAlarm (this, t); } }
protected virtual void OnTimerTick(TimerEventArgs e) { EventHandler <TimerEventArgs> handler = TimerTick; if (handler != null) { handler(this, e); } }
private void ReconnectTimer_Elapsed(object sender, TimerEventArgs e) { var _timer = sender as AVTimer; if (state == Status.Offline) { if (_timer != null) { if (_timer.Executed <= this.ReconnectOptions.Retry && CanReconnect) { AutoReconnect(); PrintLog(string.Format("reconnect for {0} times,", _timer.Executed)); _timer.Executed += 1; if (_timer.Executed == 3) { useSecondary = true; } if (_timer.Executed == 6) { reborn = true; } } else { _timer.Stop(); _timer = null; autoReconnectionStarted = false; var reconnectFailedArgs = new AVIMReconnectFailedArgs() { ClientId = _clientId, IsAuto = true, SessionToken = _sesstionToken, FailedCode = -1 }; m_OnReconnectFailed?.Invoke(this, reconnectFailedArgs); state = Status.Offline; } } else { if (CanReconnect) { AutoReconnect(); } } } else if (state == Status.Online) { if (_timer != null) { _timer.Stop(); _timer = null; } } }
private async void CountDownElapsed(object source, TimerEventArgs e) { SocketUserMessage message = e.GetEventInfoMessage(); SocketGuildUser User = e.GetEventInfoUser(); var role = User.Guild.Roles.FirstOrDefault(x => x.Name.ToString() == "Being Dropped Out of a Helicopter"); await User.RemoveRoleAsync(role); Embed UndropEmbed = Misc.CreateHeliLandEmbed(User.Username, "Helibot Automatic Detection Service"); var msg = await message.Channel.SendMessageAsync("", false, UndropEmbed); }
private void cLabTimer1_AtTime(object sender, EventArgs e) { //this.Text = DateTime.Now.ToString(); //因沒被委派,所以使用根事件名稱(EventArgs),若要使用TimerEventArgs,則須將 e 轉型成另外一個事件資料 TimerEventArgs args = e as TimerEventArgs; // 原本的e 是最原始的,沒有事件資料,故將 e 轉型成TimerEventArgs 事件資料,以使用其事件 this.Text = args.CurrentTime.ToString(); }
/// <summary> /// Raises the <see cref="E:TimerTick"/> event. /// </summary> /// <param name="e">The <see cref="Karna.Windows.UI.TimerEventArgs"/> instance containing the event data.</param> protected override void OnTimerTick(TimerEventArgs e) { base.OnTimerTick(e); if (e.TimerId == SparkeTimer) { if (this.Visible) { ProcessSparkleTimer(); } } }
protected virtual void OnTimer(TimerEventArgs e) { Thread.Sleep(e.CountTicks); EventHandler<TimerEventArgs> temp = Timer; if (temp != null) { temp(this, e); } }
private static void T_Ring(object sender, TimerEventArgs e) { var left = Console.CursorLeft; var top = Console.CursorTop; Console.BackgroundColor = (ConsoleColor)(e.Time.Second % 15); Console.SetCursorPosition(0, 10); Console.Write($"{e.Message}{e.Time.ToUniversalTime()} "); Console.SetCursorPosition(0, 11); Console.Write($"{((TClock)sender).ToString()} Интервал = { e.Interval}"); Console.ResetColor(); }
private void OnTimerTick(object sender, TimerEventArgs e) { TimerTicked?.Invoke(this, e); if (e.TotalSeconds != 0) { return; } Stop(); GameFinished?.Invoke(this, EventArgs.Empty); }
private static TimerEventArgs SetupTimer() { Console.WriteLine("Input timer name"); string timerName = Console.ReadLine(); int min = 0; int secondsAmount = InputInteger("input seconds amount for timer", "input positive integral number!", min); TimerEventArgs timer = new TimerEventArgs(timerName, secondsAmount); return(timer); }
void SendHeartBeatingPacket(object sender, TimerEventArgs e) { PrintLog("auto heart beating ticked by timer."); #if MONO || UNITY Dispatcher.Instance.Post(() => { KeepAlive(); }); #else KeepAlive(); #endif }
public void ReturnATwoMinuteTimeString() { //-- arrange var e = new TimerEventArgs(120); const string EXPECTED = "02:00"; //-- act string actual = e.ToString(); //-- assert Assert.AreEqual(EXPECTED, actual); }
internal void UpdateTurnTimer(TimerEventArgs timerEventArgs) { if (!timerEventArgs.Running || (timerEventArgs.PlayerSeconds <= 0 && timerEventArgs.OpponentSeconds <= 0)) { return; } ShowTimers(); LblTurnTime.Text = $"{(timerEventArgs.Seconds / 60) % 60:00}:{timerEventArgs.Seconds % 60:00}"; LblPlayerTurnTime.Text = $"{(timerEventArgs.PlayerSeconds / 60) % 60:00}:{timerEventArgs.PlayerSeconds % 60:00}"; LblOpponentTurnTime.Text = $"{(timerEventArgs.OpponentSeconds / 60) % 60:00}:{timerEventArgs.OpponentSeconds % 60:00}"; }
internal void TesterUpdateClockHandler(object sender, TimerEventArgs tea) { // ADDED FEATURE: Set the cursor position in the console window. Console.SetCursorPosition(_top, _left); // Display the value stored in the TimerEventArgs. Console.Write ("{0}. ", tea.CurrentIteration.ToString("000")); // Display the current time. DateTime dt = DateTime.Now; Console.WriteLine ("{0}:{1}:{2}", dt.Hour.ToString("00"), dt.Minute.ToString("00"), dt.Second.ToString("00")); }
public void Update(float dt) { if (intervals == 0) return; currentTime += dt; if (currentTime >= goalTime) { if(OnTimerFire != null){ TimerEventArgs args = new TimerEventArgs(){TimeOffset = currentTime - goalTime}; currentTime = 0; intervals--; OnTimerFire(this, args); } } }
private void TimerTick(object sender, TimerEventArgs e) { if (this.IsRunning == false) { return; } var timeElapsed = SystemTime.Now().Subtract(this.StartedAt); if (timeElapsed <= this.Duration) { return; } this.timer.Change(int.MaxValue, 100); this.IsRunning = false; this.Finished = true; this.StartedAt = DateTime.MinValue; }
// This method is called by the subscriber to start the time. internal void RunTheClock() { // Loop until counter hits 100. while (_counter <= 100) { // Sleep for a second. System.Threading.Thread.Sleep (1000); // See if there are any subscribers. if (null != OnUpdateClock) { // Create a new TimerEventArgs object providing the // value of the counter. TimerEventArgs tea = new TimerEventArgs(_counter); // Signal the subscribers. OnUpdateClock (this, tea); } // Increment the counter. _counter++; } }
/// <summary> /// Executes a scheduled task. /// </summary> /// <param name="taskId">The task id.</param> /// <param name="name">The name.</param> /// <param name="interval">The interval.</param> /// <param name="sourceCode">The source code.</param> /// <param name="language">The language.</param> /// <param name="lastRun">The last run.</param> /// <param name="lastErrorId">The last error id.</param> /// <param name="lastErrorJSON">The last error JSON.</param> /// <returns></returns> public Admin.Timer ExecuteScheduledTask( Guid taskId, string name, int interval, string sourceCode, string language, DateTime lastRun, string lastErrorId, string lastErrorJSON ) { ( "FUNCTION executeScheduledTask (init and start task event timers) /W ADHOC (!PRIVATE!)" ).Debug( 10 ); Admin.Timer timer = new Admin.Timer(); /* last time this ran, minus the interval is the starting interval */ timer.Interval = interval; timer.Name = "Compiled DB Timer Event" + Utilities.Iif( name.Length > 0, ":", "" ); timer.elapsed += new EventHandler( delegate( object e, EventArgs args ) { List<object> errors = new List<object>(); DateTime startDate = new DateTime(); startDate = DateTime.Now; DateTime endDate = new DateTime(); endDate = DateTime.MinValue; string errorJSON = ""; string errorNumber = "0"; string consoleOut = ""; try { /* and and run someone elses code */ ( "EVENT DELEGATE Task " + name + " started." ).Debug( 6 ); if( timer.Interval != interval ) { timer.Interval = interval;/* now interval should be set to the actual interval */ } using( SqlConnection cn = Site.CreateConnection( true, true ) ) { cn.Open(); using( SqlTransaction trns = cn.BeginTransaction( "Scheduled Task" ) ) { using( SqlCommand cmd = new SqlCommand( "update eventHandlers set startTime = @startTime, lock = 1 where taskId = @taskId", cn ) ) { cmd.Parameters.Add( "@taskId", SqlDbType.UniqueIdentifier ).Value = new Guid( taskId.ToString() ); cmd.Parameters.Add( "@startTime", SqlDbType.DateTime ).Value = startDate; cmd.ExecuteNonQuery(); TimerEventArgs evntArgs = new TimerEventArgs( cn, trns, lastRun, taskId, name, lastErrorId, lastErrorJSON ); object[] scriptArguments = { Main.Site, evntArgs }; object obj = Admin.ExecuteScript( sourceCode, language, "script", "main", ref scriptArguments, ref errors ); if( errors.Count == 0 ) { if( obj.GetType() == typeof( string ) ) { consoleOut = ( string )obj; } Dictionary<string, object> s = new Dictionary<string, object>(); s.Add( "errorNumber", 0 ); s.Add( "errorDesc", "Timer Event " + name + " completed without error." ); s.Add( "console", consoleOut ); errorNumber = "0"; errorJSON = s.ToJson(); trns.Commit();/* no errors occured in the script so commit the transaction */ } else { errorJSON = errors.ToJson(); errorNumber = ( ( Dictionary<string, object> )( errors[ 0 ] ) )[ "errorNumber" ].ToString(); trns.Rollback();/* one or more errors occured so rollback the transaction */ } endDate = DateTime.Now; updateEventTaskStatus( taskId, startDate, false, endDate, errorNumber, errorJSON ); ( "EVENT DELEGATE Task " + name + " ended." ).Debug( 6 ); } } } } catch( Exception excp ) { String.Format( "EVENT DELEGATE Task {0} threw and exception. {1}", name, excp.Message ).Debug( 1 ); } } ); timer.Start(); return timer; }
void OnReloadTimer(object sender, TimerEventArgs args) { reloading = false; }
internal void UpdateTurnTimer(TimerEventArgs timerEventArgs) { if (!timerEventArgs.Running || (timerEventArgs.PlayerSeconds <= 0 && timerEventArgs.OpponentSeconds <= 0)) return; ShowTimers(); LblTurnTime.Text = $"{(timerEventArgs.Seconds / 60) % 60:00}:{timerEventArgs.Seconds % 60:00}"; LblPlayerTurnTime.Text = $"{(timerEventArgs.PlayerSeconds / 60) % 60:00}:{timerEventArgs.PlayerSeconds % 60:00}"; LblOpponentTurnTime.Text = $"{(timerEventArgs.OpponentSeconds / 60) % 60:00}:{timerEventArgs.OpponentSeconds % 60:00}"; }
protected void OnAutoRefreshDisabled(object sender, TimerEventArgs e) { ScriptManager.RegisterStartupScript(this, GetType(), "AutoRefreshOff", "RaiseAppAlert('Auto refresh has been turned off due to inactivity.', 3000);", true); }
internal void LogMessage(object sender, TimerEventArgs e) { Console.WriteLine (e.CurrentTime + " - Logging message from the event delegate in the CustomTimerClass."); }
internal void DisplayMessage(object sender, TimerEventArgs e) { Console.WriteLine (e.CurrentTime + " - Called from the event delegate in the CustomTimerClass."); _callCounter++; if (_callCounter >= 10) _ctc.StopFlag = true; }
// Now the event hander will be called with a TimerEventArgs // object. The handler can choose to ignore the data in this // object, or it can use the data. In this case, we'll use // the data as part of the output. internal void DisplayLetterHandler(object sender, TimerEventArgs e) { if (_counter < _displayString.Length) { Console.Write ("\nEventsTestClass: " + e.FireTime + " - " + _displayString[_counter++ % _displayString.Length]); } else { _tc.OnAdvanceTimer -= new TimerClass.AdvanceTimerHandler (DisplayLetterHandler); _tc.StopFlag = true; } }
void HandleOverCharge (object sender, TimerEventArgs e) { OverCharge(); }
// Internal helper method that checks to see if any // objects are subscribed to the event. If any are, // their event handler method will be called through // the multicast delegate. private void RaiseTimerEvent() { if (OnAdvanceTimer != null) { // Note that before the event fires, an object of // type TimerEventArgs is created. Then, when the // event is fired, the TimerEventArgs object is // passed along with the sender. TimerEventArgs t = new TimerEventArgs(); OnAdvanceTimer (this, t); } }
// In this case, we chose to ignore the data found in the // TimerEventArgs object. If we need the data, we have access // to it later. internal void DisplayMessageHandler(object sender, TimerEventArgs e) { Console.WriteLine ("\nAnotherEventTestClass: Called from the event delegate in the TimerClass."); }
public void TimerMsg(Object sender, TimerEventArgs eventArgs) { Console.WriteLine("Person {0} received a message!", Name); }