本文整理汇总了C#中System.Windows.Threading.DispatcherTimer.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# DispatcherTimer.Stop方法的具体用法?C# DispatcherTimer.Stop怎么用?C# DispatcherTimer.Stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Threading.DispatcherTimer
的用法示例。
在下文中一共展示了DispatcherTimer.Stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteWebRequest
private void ExecuteWebRequest(string url, Action<string> callback, Action<Exception> error)
{
DispatcherTimer timer = new DispatcherTimer();
// create a web client to fetch the URL results
WebClient webClient = new WebClient();
webClient.DownloadStringCompleted += (s, e) =>
{
timer.Stop();
try
{
string result = e.Result;
callback(result);
}
catch (Exception ex)
{
error(ex);
}
};
// initiate the download
webClient.DownloadStringAsync(new Uri(url));
// create a timeout timer
timer.Interval = TimeSpan.FromSeconds(5);
timer.Start();
timer.Tick += (s, e) =>
{
timer.Stop();
webClient.CancelAsync();
error(new TimeoutException());
};
}
示例2: DispatcherPoll
public static void DispatcherPoll(Func<bool> condition, Action action, int waitLoops, int waitTime)
{
int i = 0;
var timer = new DispatcherTimer()
{
Interval = new TimeSpan(waitTime),
Tag = 0
};
timer.Tick += (sender, args) =>
{
if (i == waitLoops)
{
timer.Stop();
}
else
{
if (condition())
{
timer.Stop();
action();
}
else
{
++i;
}
}
};
timer.Start();
}
示例3: ContextActionsRenderer
public ContextActionsRenderer(CodeTextEditor editor, TextMarkerService textMarkerService)
{
if (editor == null) throw new ArgumentNullException(nameof(editor));
_editor = editor;
_textMarkerService = textMarkerService;
editor.TextArea.Caret.PositionChanged += CaretPositionChanged;
editor.KeyDown += ContextActionsRenderer_KeyDown;
_providers = new ObservableCollection<IContextActionProvider>();
_providers.CollectionChanged += providers_CollectionChanged;
editor.TextArea.TextView.ScrollOffsetChanged += ScrollChanged;
_delayMoveTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(DelayMoveMilliseconds) };
_delayMoveTimer.Stop();
_delayMoveTimer.Tick += TimerMoveTick;
if (editor.IsLoaded)
{
HookupWindowMove();
}
else
{
editor.Loaded += OnEditorLoaded;
}
}
示例4: OnNavigatedTo
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
//Networking.DeleteFile("CurrentGame");
//Networking.DeleteFile("Players");
//Check if a game in progress has already been saved and continue it
string data = Networking.LoadData("CurrentGame");
if (data != "" && MessageBox.Show("Would you like to resume the game with id of " + data, "Continue Game", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
NavigationService.Navigate(new Uri("/GamePage.xaml?gameid=" + data, UriKind.Relative));
else
{
_timer = new DispatcherTimer();
_timer.Interval = TimeSpan.FromMilliseconds(250);
_timer.Tick += (o, arg) => ScanPreviewBuffer();
//The timer auto-starts so it needs to be stopped here
_timer.Stop();
}
//Login to the server
Networking.Login();
_cam = new PhotoCamera();
_cam.Initialized += cam_Initialized;
video.Fill = _videoBrush;
_videoBrush.SetSource(_cam);
_videoBrush.RelativeTransform = new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = 90 };
}
示例5: NewsItemFullPage
public NewsItemFullPage()
{
InitializeComponent();
_m = Marker.GetInstance();
_cf = CategoryConfigA.Config;
_sizeConfig = SizeConfig2;
//_isSubscribed = false;
if (UserConfig.FontSize == FontSizes.xsmall)
_sizeConfig = SizeConfig0;
else if (UserConfig.FontSize == FontSizes.small)
_sizeConfig = SizeConfig1;
else if (UserConfig.FontSize == FontSizes.medium)
_sizeConfig = SizeConfig2;
else if (UserConfig.FontSize == FontSizes.large)
_sizeConfig = SizeConfig3;
else if (UserConfig.FontSize == FontSizes.xlarge)
_sizeConfig = SizeConfig4;
var adsTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
adsTimer.Tick += (sender, args) =>
{
InvokeAppendContent();
adsTimer.Stop();
};
adsTimer.Start();
GeneralHelper.SetupTutorial(6, Tutorial);
}
示例6: ThreadPool
public void ThreadPool ()
{
int tid = Thread.CurrentThread.ManagedThreadId;
bool called = false;
Enqueue (() => {
DispatcherTimer dt = new DispatcherTimer ();
dt.Tick += delegate (object sender, EventArgs e) {
try {
Assert.AreSame (dt, sender, "sender");
Assert.IsNotNull (e, "e");
Assert.AreEqual (Thread.CurrentThread.ManagedThreadId, tid, "ManagedThreadId");
Assert.IsTrue (dt.IsEnabled, "IsEnabled");
dt.Stop ();
Assert.IsFalse (dt.IsEnabled, "Stop");
}
finally {
called = true;
}
};
dt.Start ();
});
EnqueueConditional (() => called);
EnqueueTestComplete ();
}
示例7: Page_ClientMain
public Page_ClientMain()
{
this.InitializeComponent();
DataContext = App.ViewModel;
DispatcherTimer tmr = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(5) };
tmr.Tick += (_1, _2) =>
{
if (MultimediaUtil.VideoInputDevices.Any())
{
if (App.ViewModel.CurCam==null)
App.ViewModel.CurCam = MultimediaUtil.VideoInputDevices[0];
WebCam.VideoCaptureDevice = App.ViewModel.CurCam;
}
//WebCam.
tmr.Stop();
};
Loaded += (_1, _2) =>
{
if (App.ViewModel.ClientType == RemotingMessage.ClientTypes.Extended)
{
/* conference.Visibility = System.Windows.Visibility.Visible;
cr_1.DataContext = App.ViewModel.ConferenceRoom[1];
cr_2.DataContext = App.ViewModel.ConferenceRoom[2];
cr_3.DataContext = App.ViewModel.ConferenceRoom[3];*/
tmr.Start();
}
};
}
示例8: MainWindowViewModel
public MainWindowViewModel()
{
_modelCore = new ModelCore();
_angleLogger = new AngleLogger(_modelCore);
//描画とFPSの表示設定
var drawer = new KinectBodyDrawer(_modelCore.KinectConnector);
ImageSource = drawer.ImageSource;
var timerForFps = new DispatcherTimer();
timerForFps.Interval = TimeSpan.FromMilliseconds(100.0);
timerForFps.Tick += (_, __) =>
{
FpsFrameArrived = _modelCore.FpsFrameArrived;
FpsDataSend = _modelCore.FpsDataSend;
};
//イベントとコマンド設定
SubscribeToModelEvents(_modelCore);
SendDataChangeToModel(_modelCore);
ConnectToServerCommand = new RelayCommand(() => _modelCore.AngleDataSender.Connect(IPAddress, Port));
DisconnectFromServerCommand = new RelayCommand(() => _modelCore.AngleDataSender.Close());
CloseWindowCommand = new RelayCommand(() =>
{
_modelCore.Dispose();
_angleLogger.Dispose();
timerForFps.Stop();
});
timerForFps.Start();
}
示例9: ShowToolTip
private void ShowToolTip()
{
if (tooltip == null)
{
tooltip = new ToolTip();
tooltip.StaysOpen = true;
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1.5);
tooltip.PlacementTarget = Element;
tooltip.Placement = PlacementMode.Right;
timer.Tick += delegate
{
tooltip.IsOpen = false;
timer.Stop();
};
}
var list = ValidationService.GetErrors(Element);
if (list.Count == 0) return;
tooltip.Content = list.OrderBy(e => e.Priority).First().ErrorContent;
if (tooltip.Content != null)
{
tooltip.IsOpen = true;
timer.Start();
}
}
示例10: Run
public override void Run(RoleBase caster, Space space, MagicArgs args)
{
targets.Add(args.Target);
for (int i = space.AllRoles().Count - 1; i >= 0; i--) {
if (targets.Count == args.Number) { break; }
RoleBase target = space.AllRoles()[i];
if (caster.IsHostileTo(target) && target.InCircle(args.Destination, args.Radius * args.Scale)) {
if (target != args.Target) { targets.Add(target); }
}
}
int index = 0;
CreateSubMagic(caster, space, args, index);
DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(200) };
EventHandler handler = null;
timer.Tick += handler = delegate {
if (caster.IsHostileTo(targets[index])) { caster.CastingToEffect(targets[index], args); }
index++;
if (index == targets.Count) {
timer.Stop();
timer.Tick -= handler;
} else {
int newInterval = timer.Interval.Milliseconds - 30;
if (newInterval <= 20) { newInterval = 20; }
timer.Interval = TimeSpan.FromMilliseconds(newInterval);
CreateSubMagic(caster, space, args, index);
}
};
timer.Start();
}
示例11: AtDelay
//public static event Action<Delegate, long> TimerEvent;
public static DispatcherTimer AtDelay(this int Milliseconds, Action Handler)
{
if (Handler == null)
return null;
var t = new DispatcherTimer
{
Interval = TimeSpan.FromMilliseconds(Milliseconds)
};
t.Tick +=
delegate
{
//var mark = DateTime.Now.Ticks;
Handler();
//if (TimerEvent != null)
// TimerEvent(Handler, DateTime.Now.Ticks - mark);
t.Stop();
};
t.Start();
return t;
}
示例12: wMain
public wMain(Host _AppObjects)
{
try
{
InitializeComponent();
lmf= MemoryField.LoadData("addresses.txt");
Tag = this.Title;
coll = new ObservableCollection<MemoryField>();
// coll.Add(new MemoryField() { Address = Convert.ToString(0x450BBC, 16), Type = "BattleTime", Comment = "" });
foreach (MemoryField mf in lmf) coll.Add(mf);
dgMemory.ItemsSource = coll;
dgMemory.Items.Refresh();
dgMemory.CanUserReorderColumns = false;
AppObjects = _AppObjects;
this.Owner = AppObjects.wMain;
_timer = new DispatcherTimer();
_timer.Tick += new EventHandler(_timer_Tick);
lsFonts = new List<string>();
foreach (FontFamily s in Fonts.SystemFontFamilies)
lsFonts.Add(s.Source);
FontFamily fm = new System.Windows.Media.FontFamily(SystemFonts.CaptionFontFamily.Source);
dgMemory.FontFamily = fm;
dgMemory.UpdateLayout();
Start_Click(null, null);
}
catch (Exception)
{
_timer.Stop();
throw;
}
}
示例13: BeginRequest
protected override void BeginRequest(RetryQueueRequest request)
{
//Adding an intentional delay here to work around a known timing issue
//with the SSME. If this is called too soon after initialization the
//request will be aborted with no indication raised from the SSME.
//TODO: Remove this workaround once the SSME has been fixed.
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromMilliseconds(250);
EventHandler tickHandler = null;
tickHandler = (s, e) =>
{
SegmentInfo segment = null;
List<StreamInfo> streams = null;
var streamSelectionRequest = request as StreamSelectionRequest;
if (streamSelectionRequest != null)
{
streams = streamSelectionRequest.Streams.ToList();
segment = streamSelectionRequest.Segment;
}
else
{
var streamModifyRequest = request as StreamModifyRequest;
if (streamModifyRequest != null)
{
streams = streamModifyRequest.Streams.ToList();
segment = streamModifyRequest.Segment;
}
}
segment.SelectStreamsAsync(streams, request);
timer.Tick -= tickHandler;
timer.Stop();
};
timer.Tick += tickHandler;
timer.Start();
}
示例14: QuestionView
public QuestionView()
{
InitializeComponent();
defaultAnswerButtonBrush = new Button().Background;
maxCountDown = TimeSpan.FromSeconds(30);
countDown = new DispatcherTimer();
countDown.Interval = TimeSpan.FromSeconds(1);
countDown.Tick += ((o, args) =>
{
remainingCountDown = remainingCountDown.Subtract(TimeSpan.FromSeconds(1));
Timer.Content = remainingCountDown.Seconds;
if (remainingCountDown == TimeSpan.Zero)
{
countDown.Stop();
Timer.Content = "Time's Up";
}
});
DataContextChanged += (
(o, e) =>
{
viewModel = e.NewValue as Question;
A.Background = defaultAnswerButtonBrush;
B.Background = defaultAnswerButtonBrush;
C.Background = defaultAnswerButtonBrush;
D.Background = defaultAnswerButtonBrush;
});
questionEnterAnimation = (Storyboard)Resources["QuestionEnterAnimation"];
questionLeaveAnimation = (Storyboard)Resources["QuestionLeaveAnimation"];
}
示例15: MainWindow
public MainWindow()
{
InitializeComponent();
SettingsHelper.UpgradeSettings();
SettingsHelper.IncrementLaunches();
this.AnimateSize(AnimationMode.Hide);
if (Settings.Default.HideDelay > 0)
{
_hideTimer = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(Settings.Default.HideDelay)};
_hideTimer.Tick += delegate
{
_hideTimer.Stop();
HideNotification();
};
}
_notificationQueue = new Queue<string>();
_directoryWatcher =
new DirectoryWatcher(delegate(string path) { Dispatcher.Invoke(() => { AddToFileQueue(path); }); });
_directoryWatcher.Start();
App.SuccessfullyLoaded = true;
}