void OnTimerClicked(object sender, EventArgs e) { if (_timer != null) { _timer.Stop(); _timer = null; timerLabel.Text = "Stopped!"; return; } var now = DateTime.Now; var counter = 0; _timer = timerLabel.Dispatcher.CreateTimer(); _timer.Interval = TimeSpan.FromSeconds(3); _timer.IsRepeating = true; _timer.Start(); timerLabel.Text = "Started!"; _timer.Tick += (_, _) => { var later = DateTime.Now; counter++; timerLabel.Text = $"I am on a 3 second timer! {counter} ticks => {later - now}"; }; }
/// <summary> /// Initializes static members of the <see cref="Utils"/> class. /// </summary> static Utils() { LogOutputter = Platform.CreateTimer(CoreDispatcherPriority.Background); LogOutputter.Interval = Constants.LogOutputterUpdateInterval; LogOutputter.Tick += LogOutputter_Tick; LogOutputter.IsEnabled = true; LogOutputter.Start(); }
#pragma warning restore SA1401 // Fields must be private #endregion #region Constructors /// <summary> /// Initializes a new instance of the <see cref="MediaElementCore"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="isInDesignTime">if set to <c>true</c> [is in design time].</param> public MediaElementCore(object parent, bool isInDesignTime) { Parent = parent; Logger = new GenericMediaLogger <MediaElementCore>(this); Commands = new MediaCommandManager(this); if (!isInDesignTime) { // The UI Property update timer is responsible for timely updates to properties outside of the worker threads // We use the loaded priority because it is the priority right below the Render one. UIPropertyUpdateTimer = Platform.CreateTimer(CoreDispatcherPriority.Loaded); UIPropertyUpdateTimer.Interval = Constants.UIPropertyUpdateInterval; // The tick callback performs the updates UIPropertyUpdateTimer.Tick += (s, e) => { UpdatePosition(IsOpen ? Clock?.Position ?? TimeSpan.Zero : TimeSpan.Zero); if (HasMediaEnded == false && CanReadMorePackets && (IsOpening || IsOpen)) { var bufferedLength = Container?.Components?.PacketBufferLength ?? 0d; BufferingProgress = Math.Min(1d, bufferedLength / BufferCacheLength); var oldIsBugffering = IsBuffering; var newIsBuffering = bufferedLength < BufferCacheLength; if (oldIsBugffering == false && newIsBuffering) { RaiseBufferingStartedEvent(); } else if (oldIsBugffering && newIsBuffering == false) { RaiseBufferingEndedEvent(); } IsBuffering = HasMediaEnded == false && newIsBuffering; } else { BufferingProgress = 0; IsBuffering = false; } var downloadProgress = Math.Min(1d, Math.Round((Container?.Components.PacketBufferLength ?? 0d) / DownloadCacheLength, 3)); if (double.IsNaN(downloadProgress)) { downloadProgress = 0; } DownloadProgress = downloadProgress; }; // Go ahead and fire up the continuous updates UIPropertyUpdateTimer.IsEnabled = true; UIPropertyUpdateTimer.Start(); } }
void MakeSureWeScrollToTheNewestHandShortlyIfNecessary() { if (NewestHandIsDisplayed) { _scrollToNewestHandTimer.Stop(); } else { _scrollToNewestHandTimer.Start(); } }
protected override void OnAppearing() { _timer = Dispatcher.CreateTimer(); _timer.Interval = TimeSpan.FromMilliseconds(15); _timer.IsRepeating = true; _timer.Start(); double total = polyline.StrokeDashArray[0] + polyline.StrokeDashArray[1]; _timer.Tick += (_, _) => { double secs = DateTime.Now.TimeOfDay.TotalSeconds; polyline.StrokeDashOffset = total * (secs % 1); }; }
private void UpdateTimeout() { TimeSpan timeout = TimeSpan.Zero; switch (mState) { case ProtocolState.Idle: timeout = TimeSpan.FromSeconds(5); break; case ProtocolState.InitSent: timeout = TimeSpan.FromSeconds(5); break; } mProtocolTimeout.Stop(); if (timeout != TimeSpan.Zero) { mProtocolTimeout.Interval = timeout; mProtocolTimeout.Start(); } }
void AttachToTableWith(string tableName, string processName) { bool tableFound = false; Func <IntPtr, bool> foundWindowCallback = handle => { _windowManipulator.WindowHandle = handle; tableFound = true; _watchTableTimer.Start(); return(true); }; _windowFinder.FindWindowMatching(new Regex(Regex.Escape(tableName)), new Regex(processName), foundWindowCallback); if (!tableFound) { Log.DebugFormat("Could not find table with Name: [{0}] and ProcessName : [{1}]", tableName, processName); TableClosed(); } _waitThenTryToFindTableAgainTimer.Stop(); }
/// <summary> /// Initializes a new instance of the <see cref="AcxiomTabViewModel"/> class. /// </summary> public AcxiomTabViewModel(IAcxiomTabView view, IIntentManager intentManager, IDispatcherTimer dispatcherTimer, IDependencyInjectionContainer container, IAcxiomConstants acxiomConstants) : base(isCloseable: true) { mIntentManager = intentManager; mContainer = container; mDispatcherTimer = dispatcherTimer; mAcxiomConstants = acxiomConstants; Header = AcxiomStringResources.TabHeader; //Tab Header text HeaderTooltip = AcxiomStringResources.TabHeaderTooltip; //Tab header tooltip mBaseURL = mAcxiomConstants.ExternalSubsetGenerationUri.ToString(); PageLocation = mBaseURL; mJavaScriptHandler = new JavaScriptHandler(this); SetAsViewModelForView(view); //All is ok, start to render html UI mDispatcherTimer.Interval = TimeSpan.FromMilliseconds(100); mDispatcherTimer.Tick += CheckForHtmlReady; mDispatcherTimer.Start(); }
/* * void SetAllAges() * { * DateTime now = DateTime.Now; * _participants.ForEach(p=>p.Value.AgeDays = (now - p.Value.DateTimeBirth).Days); * } */ void StartTimer(TimeSpan interval) { _timer.Interval = interval; System.Diagnostics.Debug.WriteLine("next interval set at:{0}", interval); _timer.Start(); }
public IOverlayBoardViewModel HideBoardAfter(int seconds) { _dispatcherTimer.Interval = TimeSpan.FromSeconds(seconds); _dispatcherTimer.Start(); return(this); }
public void Run() { _dispatcherTimer.OnTime += DispatcherTimerOnOnTime; _dispatcherTimer.Start(); }
public void TableLostHandler() { _watchTableTimer.Stop(); _waitThenTryToFindTableAgainTimer.Start(); }
protected void StartClock() { _timer.Start(); }