-
September 23rd, 2010, 02:02 AM
#1
Issue With Dispatch Timer
I have a WPF application. I have a panel that I want to repopulate every 1 minute getting data from the network. I know that I can use the DispatcherTimer class to set the timespan for ticks and make my code execute in every 1 minute.
The problem here is the my GUI freezes and becomes unresponsive as my code is busy fetching data from the network. I would like to know that is there any way in WPF to get rid of it as this is a new World for me.
I am doing it like this:
DispatcherTimer timer = new DispatcherTimer();
Windiw_Loaded()
{
timer.Interval = TimeSpan.FromMilliseconds(1000);
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
}
private void timer_Tick(object sender, EventArgs e)
{
FetchNewAttendence();
}
This code freezes my GUI. Please help.
Thanks,
Namrata
-
September 25th, 2010, 04:19 PM
#2
Re: Issue With Dispatch Timer
Start a new thread (or use the BackgroundWorker class) and put the retrieval code there.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|