Questions tagged [dispatchertimer]

DispatcherTimer is a .Net class that provides timers that are integrated into the Dispatcher queue which is processed at a specified interval of time and at a specified priority.

216 questions
20
votes
1 answer

dispatch_source_cancel on a suspended timer causes EXC_BAD_INSTRUCTION

I'm trying to cancel and then release a suspended timer but when I invoke 'dispatch_release' on it, I immediately get EXC_BAD_INSTRUCTION. Is this not a valid set of actions to take on a timer? Timer creation & suspension: @interface SomeClass:…
Jonas Gardner
  • 2,458
  • 5
  • 22
  • 28
18
votes
1 answer

DispatcherTimer not firing in WPF Application

I am trying to understand why the DispatcherTimer contained within SingletonWithTimer is not firing in the following WPF application. I've been researching this for a couple of days and cannot seem to get to the bottom it. This application is the…
Jack
  • 1,477
  • 15
  • 20
18
votes
6 answers

DispatcherTimer not firing Tick event

I have a DispatcherTimer i have initialised like so: static DispatcherTimer _timer = new DispatcherTimer(); static void Main() { _timer.Interval = new TimeSpan(0, 0, 5); _timer.Tick += new EventHandler(_timer_Tick); …
harryovers
  • 3,087
  • 2
  • 34
  • 56
13
votes
1 answer

Task.Delay vs DispatcherTimer?

I'm considering use Task.Delay() for a non-stop timer, because it's more simple and readable. As I'm new to .NET, I see no significant difference between the two codes. Can you show me the difference (if there is any) between them? // Create…
NoName
  • 7,940
  • 13
  • 56
  • 108
11
votes
1 answer

how to make DispatcherTimer events smoother in WPF?

In my WPF application, the user presses a button to start a 3D model rotating smoothly, and lets up on the button to stop the rotation. To do this, I create a DispatcherTimer: DispatcherTimer timer = new DispatcherTimer(); timer.Tick += new…
M Katz
  • 5,098
  • 3
  • 44
  • 66
11
votes
2 answers

Dispose or kill DispatcherTimer object and Accessing DispatcherTimer object

Question 1: Hi, I would like to know is there a way by which I can dispose or kill the object of DispatcherTimer and create a new object of same name? Question 2: Can I access the DispatcherTimer object in some other class if it is set to Public?
ahmad05
  • 438
  • 2
  • 6
  • 23
9
votes
6 answers

Performance for Timer vs DispatcherTimer

I don't have a specific scenario in mind, but this question just crossed my mind while I was thinking of scenarios where I may want to use a Timer over a DispatcherTimer. In the scenario where I have to perform come computationally intensive task…
K Mehta
  • 10,323
  • 4
  • 46
  • 76
8
votes
3 answers

Will this Timer be released from memory?

Consider this pair of functions in C#: void func1() { DispatcherTimer tmr = new DispatcherTimer(); tmr.Interval = TimeSpan.FromSeconds(5); tmr.Tick += func2; tmr.Start(); } void func2(object a, EventArgs b) { // Called every 5…
JoeCool
  • 4,392
  • 11
  • 50
  • 66
8
votes
2 answers

DispatcherTimer and UI refresh limits in C# silverlight

Again I apologize for a question that might be simple to all of you. I have a limited understanding of what goes behind the scenes in Silverlight. I have a charting app (Visiblox) that I use as a rolling scope updated every 20ms, adding and removing…
PaulG
  • 177
  • 5
  • 11
8
votes
2 answers

send a extra argument in Dispatchertimer.Tick event

my question is how can i send some arguments in Dispatchertimer.Tick event here is the code: what i wanted to is receive a integer value at dispatcheTimer_Tick dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); private void…
ahmad05
  • 438
  • 2
  • 6
  • 23
6
votes
3 answers

Stopping DispatcherTimer in its own anonymous Tick event handler

Is it safe to do something like this: private void MyFunction() { DispatcherTimer timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 1); timer.Tick += (object sender, object e) => { timer.Stop(); //…
K Mehta
  • 10,323
  • 4
  • 46
  • 76
6
votes
2 answers

idle state detection silverlight 4 application

What's the best way to detect idle state for a silverlight application? I have read quite a few articles on the net by now and usually they are either for wpf/mobile apps etc. I have created a DispatcherTimer which locks the screen after 5 minutes…
user642770
  • 415
  • 5
  • 18
6
votes
1 answer

How can I test a class that uses DispatcherTimer?

I've found a couple of Stack Overflow questions along with a couple of blog posts that already touch on this topic, but unfortunately none of them are meeting my needs. I'll just start with some sample code to show what I'd like to accomplish. using…
soapergem
  • 9,263
  • 18
  • 96
  • 152
6
votes
3 answers

Timer in AudioPlaybackAgent

I have an Internet radio app that uses BackgroundAudioPlayer. I need a timer in the Audio Playback Agent that will update the track title of the currently playing track of the BAP that is pulled from the Internet radio station's API. Adding a…
5
votes
4 answers

DispatchTimer - Prevent the tick event to be triggered if the previous tick is still running

In a Silverlight app, I have a block of code that has to run every 500ms. I am planning o use a DispatcherTimer to achieve this (see code below). DispatcherTimer dt = new DispatcherTimer(); dt.Interval = new TimeSpan(0, 0, 0, 0, 500); // 500…
Martin
  • 39,309
  • 62
  • 192
  • 278
1
2 3
14 15