Silverlight assigns an event at a specific time

I am trying to find a way to fire a Silverlight event at a specific time of day. The application will be launched from the browser and will work all the time. I found several methods that use a timer to trigger an event every minute, and then check to see if it’s the right time to do something, but it sounds messy. Is there a way to launch an event, for example, at 10:34 a.m. on September 23, 2010?

+6
events silverlight scheduling
source share
4 answers

If you want the timer to withstand the reload of the application, I suggest using a poll and moving the scheduled tasks somewhere.

Otherwise, simply set the timer interval to the time interval between the current and the scheduled time.

+2
source share

I do not believe that there is such a feature in Silverlight. If you do not like the approach to the survey, you can always get the difference between DateTime.Now and the target time and set such a timer for a long time. Although I do not know how reliable it is.

0
source share

I am not aware of any control that does what you ask for. Here are the timers I'm familiar with:

  • System.Threading.Timer (interval) - generate repeating events (purely digital time without user interface updates)
  • System.Windows.Threading.DispatcherTimer (..) - Use in a streaming context (WPF / Silverlight)
  • System.Windows.Forms.Timer () - use the Windows forms message loop (WinForms in the main user interface thread)

I find it best to use DispatcherTimer at intervals of, say, 30 seconds, and then match the actual time with the expected time and date. From what I remember, such timers are designed for small intervals, so large intervals will be less accurate. (I'm talking about a fix)

EDIT : MSDN timing notes : "Timers do not guarantee execution exactly when a time interval occurs, but they are not guaranteed to be executed before a time interval occurs. This is because DispatcherTimer operations are placed on Dispatcher like other operations. When the DispatcherTimer operation is performed, depending on the other jobs in the queue and their priorities. "

0
source share

Thanks for answers. I still haven’t found anything, but I used StoryBoard as a synchronization component, since DispatcherTimer works in the same thread as the user interface, while StoryBoard does not.

Here you can learn more about the comparison between the two.

http://blogs.silverlight.net/blogs/msnow/archive/2009/11/09/69731.aspx

0
source share

All Articles