This is a followup question to my previous question: HttpWebRequest from AudioPlayerAgent
I am looking for a way to run a function every 20-30 seconds from inside my BackgroundAudioPlayer in order to query a web server.
Currently, I'm trying to use a timer in this fashion:
public AudioPlayer()
{
if (!_classInitialized)
{
_classInitialized = true;
// Subscribe to the managed exception handler
Deployment.Current.Dispatcher.BeginInvoke(delegate
{
Application.Current.UnhandledException += AudioPlayer_UnhandledException;
});
trackTimer = new Timer(TrackTimerTick, null, 0, 2000);
}
}
However, whenever I call NotifyComplete(), the timer no longer ticks. Is it possible to make this work? If so, how?