I wish to execute a function at an interval of 1 or so minutes. How can I achieve this in Windows Phone 8.
I am not looking for background agents. The app will be running in the foreground. What are my options?
1
votes
4 Answers
10
votes
you can use the DispatcherTimer Class
private DispatcherTimer dispatcherTimer;
// Constructor
public MainPage()
{
InitializeComponent();
dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
dispatcherTimer.Start();
}
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
//do whatever you want to do here
}
Refer: (http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatchertimer(v=vs.110).aspx)
5
votes
3
votes
1
votes