本文整理匯總了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();
}
示例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();
}
}
示例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);
}
示例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();
};
}
示例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();
}
示例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();
}
示例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;
};
}
示例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();
};
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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; });
}
示例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();
}
示例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();
}
}
示例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;
}