當前位置: 首頁>>代碼示例>>C#>>正文


C# DispatcherTimer.Stop方法代碼示例

本文整理匯總了C#中Windows.UI.Xaml.DispatcherTimer.Stop方法的典型用法代碼示例。如果您正苦於以下問題:C# DispatcherTimer.Stop方法的具體用法?C# DispatcherTimer.Stop怎麽用?C# DispatcherTimer.Stop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Windows.UI.Xaml.DispatcherTimer的用法示例。


在下文中一共展示了DispatcherTimer.Stop方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnNavigatedTo

 /// <summary>
 /// Invoked when this page is about to be displayed in a Frame.
 /// </summary>
 /// <param name="e">Event data that describes how this page was reached.
 /// This parameter is typically used to configure the page.</param>
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     timer = new DispatcherTimer();
     timer.Interval = TimeSpan.FromSeconds(1);
     timer.Tick += Timer_Tick;
     timer.Stop();
 }
開發者ID:toolboc,項目名稱:PhotonRGBHeartRateDisplay-,代碼行數:12,代碼來源:MainPage.xaml.cs

示例2: InjectAsyncExceptions

        // *** Methods ***

        public static async void InjectAsyncExceptions(Task task)
        {
            // Await the task to allow any exceptions to be thrown

            try
            {
                await task;
            }
            catch (Exception e)
            {
                // If we are currently on the core dispatcher then we can simply rethrow the exception
                // NB: This will occur if awaiting the task returned immediately

                CoreDispatcher dispatcher = CoreApplication.GetCurrentView().CoreWindow.Dispatcher;

                if (dispatcher.HasThreadAccess)
                    throw;

                // Otherwise capture the exception with its original stack trace

                ExceptionDispatchInfo exceptionDispatchInfo = ExceptionDispatchInfo.Capture(e);

                // Re-throw the exception via a DispatcherTimer (this will then be captured by the Application.UnhandledException event)

                DispatcherTimer timer = new DispatcherTimer();
                timer.Tick += (sender, args) =>
                {
                    timer.Stop();
                    exceptionDispatchInfo.Throw();
                };
                timer.Start();
            }
        }
開發者ID:deepakpal9046,項目名稱:Okra.Core,代碼行數:35,代碼來源:ExceptionHelper.cs

示例3: OnButtonClick

        async void OnButtonClick(object sender, RoutedEventArgs e) {
            MessageDialog msgdlg = new MessageDialog("Choose a color", "How to Async #1");
            msgdlg.Commands.Add(new UICommand("Red", null, Colors.Red));
            msgdlg.Commands.Add(new UICommand("Green", null, Colors.Green));
            msgdlg.Commands.Add(new UICommand("Blue", null, Colors.Blue));

            // Start a five-second timer
            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(5);
            timer.Tick += OnTimerTick;
            timer.Start();

            // Show the MessageDialog
            asyncOp = msgdlg.ShowAsync();
            IUICommand command = null;

            try {
                command = await asyncOp;
            }
            catch (Exception) {
                // The exception in this case will be TaskCanceledException
            }

            // Stop the timer
            timer.Stop();

            // If the operation was canceled, exit the method
            if (command == null) {
                return;
            }

            // Get the Color value and set the background brush
            Color clr = (Color)command.Id;
            contentGrid.Background = new SolidColorBrush(clr);
        }
開發者ID:ronlemire2,項目名稱:UWP-Testers,代碼行數:35,代碼來源:HowToCancelAsyncPage.xaml.cs

示例4: NotificationStatusControl

 public NotificationStatusControl()
 {
     this.InitializeComponent();
     (Resources["rotateAnimetion"] as Storyboard).Begin();
     VisualStateManager.GoToState(this, "StateNotConnection", true);
     State = NotificationState.NotConnection;
     notificationTimer = new DispatcherTimer();
     notificationTimer.Tick += (s, e) =>
     {
         switch (BeforeState)
         {
             case NotificationState.Connection:
                 VisualStateManager.GoToState(this, "StateConnection", true);
                 State = NotificationState.Connection;
                 break;
             case NotificationState.NotConnection:
                 VisualStateManager.GoToState(this, "StateNotConnection", true);
                 State = NotificationState.NotConnection;
                 break;
             case NotificationState.Notification:
                 VisualStateManager.GoToState(this, "StateNotification", true);
                 State = NotificationState.Notification;
                 break;
         }
         notificationTimer.Stop();
     };
 }
開發者ID:garicchi,項目名稱:Neuronia,代碼行數:27,代碼來源:NotificationStatusControl.xaml.cs

示例5: Load

        public async Task Load()
        {
            var x = 0;
            var max = 20;
            var y = 0;

            var items = ResourceFileParser.GetKeysBasedOn(@"Common\StandardStyles.xaml", "AppBarButtonStyle");
            t = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(50) };
            t.Tick += (s, e) =>
                          {
                              t.Stop();

                              for (int index = x; index < items.Count; index++)
                              {
                                  y++;
                                  var i = items[index];
                                  buttonGroup.Items.Add(i);

                                  if (y % max == 0)
                                  {
                                      x = index;
                                      if (y < items.Count)
                                          t.Start();
                                      break;
                                  }
                              }
                          };

            t.Start();
        }
開發者ID:quandtm,項目名稱:exXAMLate,代碼行數:30,代碼來源:IconViewModel.cs

示例6: Activate

 void Activate()
 {
     // this delay allows the ext splash image to load and render
     var _Timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(1000) };
     _Timer.Tick += (s, e) =>
     {
         _Timer.Stop();
         Window.Current.Activate();
     };
     _Timer.Start();
 }
開發者ID:noriike,項目名稱:xaml-106136,代碼行數:11,代碼來源:App.xaml.cs

示例7: InitButtonTimer

        private void InitButtonTimer()
        {
            if (_buttonTimer != null) return;

            _buttonTimer = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(2000)};
            _buttonTimer.Tick += (sender, e) =>
            {
                _buttonTimer.Stop();
                _lastButtonId = string.Empty;
            };
        }
開發者ID:andyhammar,項目名稱:ToddlerVideo,代碼行數:11,代碼來源:MainPage.xaml.cs

示例8: ThrottleTimer

        internal ThrottleTimer(int milliseconds, Action handler)
        {
            Action = handler;
            throttleTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds((double)milliseconds) };

            throttleTimer.Tick += delegate(object s, object e)
            {
                if (Action != null)
                {
                    Action.Invoke();
                }
                throttleTimer.Stop();
            };
        }
開發者ID:SuperMap,項目名稱:iClient-for-Win8,代碼行數:14,代碼來源:ThrottleTimer.cs

示例9: After

        /// <summary>
        /// <para>Executes the user code after a specified duration.</para>
        /// <para>Note: This method produces a working EventToken</para>
        /// </summary>
        /// <param name="duration"></param>
        /// <param name="timeType"></param>
        /// <returns>A token representing the animation</returns>
        public override EventToken After(double duration, OrSo timeType)
        {
            DispatcherTimer timer = new DispatcherTimer();
            EventToken placeholder = EventToken.PlaceholderToken();

            timer.Interval = GetTimeSpan(duration, timeType);
            timer.Tick += (s, e) =>
            {
                timer.Stop();
                placeholder.PassOn(Now());
            };
            timer.Start();

            return placeholder;
        }
開發者ID:ThatLousyGuy,項目名稱:Monolith,代碼行數:22,代碼來源:CodeAnimator.cs

示例10: MakeMoveIfCorrectTurn

 private void MakeMoveIfCorrectTurn()
 {
     if (_viewModel.NextMove == _computerColor)
       {
     // make a move after a short delay.
     var timer = new DispatcherTimer();
     timer.Interval = TimeSpan.FromSeconds(0.5);
     timer.Tick += (s, e2) =>
     {
       MakeNextMove();
       timer.Stop();
     };
     timer.Start();
       }
 }
開發者ID:ColinEberhardt,項目名稱:ReversiEight,代碼行數:15,代碼來源:ComputerOpponent.cs

示例11: InitControls

        private void InitControls()
        {
            if (mainGrid == null)
            {

                mainGrid = (Grid)GetTemplateChild("mainGrid");
                spChildren = (StackPanel)GetTemplateChild("spChildren");

                Render();

                DispatcherTimer dtOnce = new DispatcherTimer();
                dtOnce.Interval = TimeSpan.FromSeconds(1.5);
                dtOnce.Tick += (o, e) => { ShowMandatory(); dtOnce.Stop(); };
                dtOnce.Start();
            }
            
        }
開發者ID:liquidboy,項目名稱:X,代碼行數:17,代碼來源:DataEntryPanel.cs

示例12: Shell

        public Shell() : base()
        {
            this.ViewModel = new ShellViewModel();
			loadingTimer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(600) };
            loadingTimer.Tick += ((sender, e) =>
            {
                loadingTimer.Stop();
                loadingProgressRing.IsActive = false;
                extendedLoadingHome.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            });
            this.InitializeComponent();

            var applicationView = ApplicationView.GetForCurrentView();

            this.Loaded += MainPage_Loaded;
            FullScreenService.FullScreenModeChanged += ((sender, e) => { isFullScreen = e; });
        }
開發者ID:mvegaca,項目名稱:EventsCode,代碼行數:17,代碼來源:Shell.xaml.cs

示例13: SplashScreenPage

        public SplashScreenPage()
        {
            InitializeComponent();

            _navigationHelper = new NavigationHelper(this);
            _navigationHelper.LoadState += NavigationHelper_LoadState;
            _navigationHelper.SaveState += NavigationHelper_SaveState;

            // Login on Gitter API using Timer
            var dispatcherTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(500) };

            dispatcherTimer.Tick += async (sender, o) =>
            {
                dispatcherTimer.Stop();
                await ViewModelLocator.Login.LoginAsync();
            };
            dispatcherTimer.Start();
        }
開發者ID:nmetulev,項目名稱:Modern-Gitter,代碼行數:18,代碼來源:SplashScreenPage.xaml.cs

示例14: Tick

        public void Tick(DispatcherTimer timer)
        {
            if (Player.IsAlive)
            {
                Player.Tick(Board);

                Board.Tick();

                // Update timer-interval (based on Level)
                Level = (Player.Length / 2);
                timer.Interval = TimeSpan.FromMilliseconds(1000 - (Level * 100));
            }
            else
            {
                timer.Stop();

                // Board.ResetLEDGameOver();
            }
        }
開發者ID:joakimglysing,項目名稱:ProjectKallax,代碼行數:19,代碼來源:Game.cs

示例15: navigateToIndstil

        public void navigateToIndstil()
        {
            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = new System.TimeSpan(0, 0, 0, 0, 100);
            timer.Tick += (object sender, object e) =>
            {
                if (flag)
                {
                    flag = false;
                    timer.Stop();
                    game.Exit();
                    Window.Current.Content = _indstil;
                    Window.Current.Activate();
                }

            };
            timer.Start();
            flag = true;
        }
開發者ID:Wirack,項目名稱:vendespil,代碼行數:19,代碼來源:GamePage.xaml.cs


注:本文中的Windows.UI.Xaml.DispatcherTimer.Stop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。