本文整理汇总了C#中System.Windows.Threading.DispatcherTimer.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# System.Windows.Threading.DispatcherTimer.Stop方法的具体用法?C# System.Windows.Threading.DispatcherTimer.Stop怎么用?C# System.Windows.Threading.DispatcherTimer.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Threading.DispatcherTimer
的用法示例。
在下文中一共展示了System.Windows.Threading.DispatcherTimer.Stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FocusMonitor
ObservableBackwardsRingBuffer<WeakReference> focussedElementBuffer = new ObservableBackwardsRingBuffer<WeakReference>(10);//because we don't know which controls to track until after the RapidFindReplaceControl is created, we must record a list and pick the first one that is pertinent
public FocusMonitor(DependencyObject focusScopeToMonitor)
{
if (focusScopeToMonitor!=null && FocusManager.GetIsFocusScope(focusScopeToMonitor))
{
this.focusScopeToMonitorRef = new WeakReference(focusScopeToMonitor);
}
//poll for focus to track ordering of focused elements
System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
dispatcherTimer.Tick += delegate{
if (focusScopeToMonitorRef!=null && focusScopeToMonitorRef.IsAlive)
{
IInputElement logicalFocus = FocusManager.GetFocusedElement(focusScopeToMonitorRef.Target as DependencyObject);
IInputElement keyboardFocus = Keyboard.FocusedElement;
if (logicalFocus == keyboardFocus && keyboardFocus is UIElement)
{
//if(RapidFindReplaceControl.GetIsFindable(keyboardFocus as UIElement))
//lastKeyboardFocusRef = new WeakReference(keyboardFocus as DependencyObject);
if (focussedElementBuffer.Count==0 || (focussedElementBuffer[0] != null && focussedElementBuffer[0].IsAlive && focussedElementBuffer[0].Target != keyboardFocus))
focussedElementBuffer.AddItem(new WeakReference(keyboardFocus as UIElement));
}
}
else
dispatcherTimer.Stop();
};
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100);
dispatcherTimer.Start();
}
示例2: timerRun
private void timerRun()
{
timerField = new System.Windows.Threading.DispatcherTimer();
timerField.Tick += new EventHandler(timerTick);
SetServerCheckInterval();
var actAcc = clientDB.ActiveAccount();
myCurrentImap = new List<Imap>();
foreach (string s in actAcc.Keys)
{
myCurrentImap.Add(new Imap(Cryptography.Decrypt(s), Cryptography.Decrypt(actAcc[s])));
}
try
{
foreach (Imap im in myCurrentImap)
{
im.Connection();
clientDB.UpdateAccountMessages(Cryptography.Encrypt(im.currentEmail), im.Connections.Inbox.Count);
}
}
catch
{
timerField.Stop();
}
timerField.Start();
}
示例3: AutoHideSoon
private void AutoHideSoon()
{
if (autoHideCalled)
return;
autoHideCalled = true;
var timer = new System.Windows.Threading.DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(3);
timer.Tick += (sender, args) =>
{
timer.Stop();
try
{
if (this.Visibility == System.Windows.Visibility.Visible)
{
this.Close();
}
}
catch
{
// just hide any error - probably means the user found some other way to hide us!
}
};
}
示例4: ButtonStart_Click
private async void ButtonStart_Click(object sender, RoutedEventArgs e)
{
ButtonStart.IsEnabled = false;
Slider_Duration.IsEnabled = false;
TimeSpan duration = TimeSpan.FromSeconds(this.Slider_Duration.Value);
System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
timer.Start();
timer.Tick += timer_Tick;
LabelCountdown.Content = Convert.ToInt32(duration.TotalSeconds);
try
{
await StartTimerAsync(duration);
}
finally
{
timer.Stop();
ButtonStart.IsEnabled = true;
Slider_Duration.IsEnabled = true;
LabelCountdown.Content = 0;
}
}
示例5: MainPage
public MainPage(IDictionary<string, string> initParams)
{
InitializeComponent();
HtmlPage.RegisterScriptableObject("SilverlightApp", this);
// timer
_timer = new System.Windows.Threading.DispatcherTimer();
_timer.Interval = new TimeSpan(0, 0, 0, 0, 200); // 200 Milliseconds
_timer.Tick += new EventHandler(timer_Tick);
_timer.Stop();
// add events
media.BufferingProgressChanged += new RoutedEventHandler(media_BufferingProgressChanged);
media.DownloadProgressChanged += new RoutedEventHandler(media_DownloadProgressChanged);
media.CurrentStateChanged += new RoutedEventHandler(media_CurrentStateChanged);
media.MediaEnded += new RoutedEventHandler(media_MediaEnded);
media.MediaFailed += new EventHandler<ExceptionRoutedEventArgs>(media_MediaFailed);
// get parameters
if (initParams.ContainsKey("id"))
_htmlid = initParams["id"];
if (initParams.ContainsKey("file"))
_mediaUrl = initParams["file"];
if (initParams.ContainsKey("autoplay") && initParams["autoplay"] == "true")
_autoplay = true;
if (initParams.ContainsKey("debug") && initParams["debug"] == "true")
_debug = true;
if (initParams.ContainsKey("width"))
Int32.TryParse(initParams["width"], out _width);
if (initParams.ContainsKey("height"))
Int32.TryParse(initParams["height"], out _height);
// set stage and media sizes
if (_width > 0)
LayoutRoot.Width = media.Width = this.Width = _width;
if (_height > 0)
LayoutRoot.Height = media.Height = this.Height = _height;
// debug
textBox1.Visibility = (_debug) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
textBox1.IsEnabled = false;
textBox1.Text = "id: " + _htmlid + "\n" +
"file: " + _mediaUrl + "\n";
media.AutoPlay = _autoplay;
if (!String.IsNullOrEmpty(_mediaUrl)) {
setSrc(_mediaUrl);
}
// full screen settings
Application.Current.Host.Content.FullScreenChanged += new EventHandler(DisplaySizeInformation);
Application.Current.Host.Content.Resized += new EventHandler(DisplaySizeInformation);
FullscreenButton.Visibility = System.Windows.Visibility.Collapsed;
// send out init call
HtmlPage.Window.Invoke("html5_MediaPluginBridge_initPlugin", _htmlid);
}
示例6: MoveToMainMenu
public void MoveToMainMenu()
{
var timer = new System.Windows.Threading.DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 3);
timer.Tick += (delegate {
NavigationService.Navigate(new Uri("/Screen/Menu.xaml", UriKind.RelativeOrAbsolute));
timer.Stop();
});
timer.Start();
}
示例7: ThrottleTimer
/// <summary>
/// Initializes a new instance of the <see cref="ThrottleTimer"/> class.
/// </summary>
/// <param name="milliseconds">Milliseconds to throttle.</param>
/// <param name="handler">The delegate to invoke.</param>
internal ThrottleTimer(int milliseconds, Action handler)
{
Action = handler;
throttleTimer = new System.Windows.Threading.DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(milliseconds) };
throttleTimer.Tick += (s, e) =>
{
if(Action!=null)
Action.Invoke();
throttleTimer.Stop();
};
}
示例8: setTimeOut
public static void setTimeOut(Action doWork, TimeSpan time)
{
System.Windows.Threading.DispatcherTimer myDispatcherTimer = new System.Windows.Threading.DispatcherTimer();
myDispatcherTimer.Interval = time;
myDispatcherTimer.Tick += delegate(object s, EventArgs args)
{
myDispatcherTimer.Stop();
doWork();
};
myDispatcherTimer.Start();
}
示例9: MainPage
public MainPage()
{
InitializeComponent();
this.listButton.ItemsSource = (App.config).Groups;
System.Windows.Threading.DispatcherTimer tmr = new System.Windows.Threading.DispatcherTimer();
tmr.Tick += (s, a) =>
{
this.CanHandleEvent = true;
tmr.Stop();
};
tmr.Interval = TimeSpan.FromSeconds(0.5);
tmr.Start();
}
示例10: AddProfileWindow_Loaded
private void AddProfileWindow_Loaded(object sender, RoutedEventArgs e)
{
System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
this.Opacity = 0.00;
dispatcherTimer.Tick += new EventHandler((sender1, e1) =>
{
if ((Opacity += 0.1) >= 1)
{
dispatcherTimer.Stop();
}
});
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 20);
dispatcherTimer.Start();
}
示例11: TaskTrayClass
public TaskTrayClass(Window target)
{
Text = "";
notifyIcon.BalloonTipIcon = ToolTipIcon.Info;
notifyIcon.Click += NotifyIcon_Click;
notifyIcon.BalloonTipClicked += NotifyIcon_Click;
// 接続先ウィンドウ
targetWindow = target;
LastViewState = targetWindow.WindowState;
// ウィンドウに接続
if (targetWindow != null) {
targetWindow.Closing += new System.ComponentModel.CancelEventHandler(target_Closing);
}
notifyIcon.ContextMenuStrip = new ContextMenuStrip();
// 指定タイムアウトでバルーンチップを強制的に閉じる
var balloonTimer = new System.Windows.Threading.DispatcherTimer();
balloonTimer.Tick += (sender, e) =>
{
if (notifyIcon.Visible)
{
notifyIcon.Visible = false;
notifyIcon.Visible = true;
}
balloonTimer.Stop();
};
notifyIcon.BalloonTipShown += (sender, e) =>
{
if (Settings.Instance.ForceHideBalloonTipSec > 0)
{
balloonTimer.Interval = TimeSpan.FromSeconds(Math.Max(Settings.Instance.ForceHideBalloonTipSec, 1));
balloonTimer.Start();
}
};
notifyIcon.BalloonTipClicked += (sender, e) => balloonTimer.Stop();
notifyIcon.BalloonTipClosed += (sender, e) => balloonTimer.Stop();
}
示例12: Countdown
void Countdown(int count, TimeSpan interval, Action<int> ts)
{
var dt = new System.Windows.Threading.DispatcherTimer();
dt.Interval = interval;
dt.Tick += (_, a) =>
{
if (count-- == 0)
dt.Stop();
else
ts(count);
};
ts(count);
dt.Start();
}
示例13: OSM_AddressChanged
private void OSM_AddressChanged(object sender, UrlEventArgs e)
{
System.Windows.Threading.DispatcherTimer dispatcher = new System.Windows.Threading.DispatcherTimer();
dispatcher.Tick += new EventHandler(KeepFocus);
dispatcher.Interval = new TimeSpan(0, 0, 1);
if (OSM.Source.ToString().Contains("?movieid=" + App.Args["/movieid"] + "&trkid=" + App.Args["/trackid"]))
{
dispatcher.Start();
OSM.Visibility = System.Windows.Visibility.Visible;
}
else
{
dispatcher.Stop();
}
}
示例14: ConnectWindow
public ConnectWindow()
{
InitializeComponent();
_udpDiscoveryClient = new UdpDiscoveryClient(
ready => { },
(name, address) => Dispatcher.Invoke((Action)(() =>
{
if (address.Contains(":?/")) // Android emulator, so use forwarded ports
{
// todo: use telnet to discover already set up port forwards, instead of hardcoding
address = address.Replace(":?/", String.Format(":{0}/", HttpForwardedHostPort));
}
var deviceItem = new MainWindow.DeviceItem
{
DeviceAddress = address,
DeviceName = name,
DeviceType =
name.StartsWith("ProtoPad Service on ANDROID Device ")
? MainWindow.DeviceTypes.Android
: MainWindow.DeviceTypes.iOS
};
if (!DevicesList.Items.Cast<object>().Any(i => (i as MainWindow.DeviceItem).DeviceAddress == deviceItem.DeviceAddress))
{
DevicesList.Items.Add(deviceItem);
}
DevicesList.IsEnabled = true;
//LogToResultsWindow("Found '{0}' on {1}", name, address);
})));
_dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
_dispatcherTimer.Tick += (s, a) =>
{
if (_ticksPassed > 2)
{
_dispatcherTimer.Stop();
if (DevicesList.Items.Count == 1) DevicesList.SelectedIndex = 0;
}
_udpDiscoveryClient.SendServerPing();
_ticksPassed++;
};
_dispatcherTimer.Interval = TimeSpan.FromMilliseconds(200);
FindApps();
}
示例15: updateMyBg
void updateMyBg()
{
try
{
using (var store = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication())
{
using (var str = store.OpenFile("bing.jpg", FileMode.Open))
{
System.Windows.Media.Imaging.WriteableBitmap wb = new System.Windows.Media.Imaging.WriteableBitmap(480, 800);
BitmapImage bimg = new BitmapImage();
bimg.SetSource(str);
image1.Source = bimg;
}
}
}
catch
{
System.Windows.Threading.DispatcherTimer tim = new System.Windows.Threading.DispatcherTimer();
tim.Interval = TimeSpan.FromSeconds(2);
tim.Tick += new EventHandler((o, e) =>
{
updateMyBg();
tim.Stop();
});
tim.Start();
}
}