This is a migrated thread and some comments may be shown as answers.
Refresh timer
9 Answers 46 Views
This is a migrated thread and some comments may be shown as answers.
Grtjn
Top achievements
Rank 1
Grtjn asked on 11 Mar 2010, 09:39 PM
Hi all,

Is there some way I can let my page refresh let's say every 5 minutes?
Probably you can do this, but I can't seem to find it...
This I would like to insert in my code-behind (C#)!

Kind regards,

Gertjan

9 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 12 Mar 2010, 08:11 AM
Hello Gertjan,

You can use DispatcherTimer to achieve your goal.

Best wishes,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Grtjn
Top achievements
Rank 1
answered on 12 Mar 2010, 09:00 AM
Ok.
So I have been searching how to use the dispatchertimer and found some code
http://www.telerik.com/community/forums/wpf/gridview/gridview-master-detail-representation-with-card-view-detail.aspx (bottom post by Milan)

My connection with the database is not via Linq2SQL, but webservice. Is there a refresh methode for webservices also?

Edit:
Should I refresh my grid, so that my page refreshes while running?
And I am using a Grid, not the RadGridView...

Kind regards,

Gertjan
0
Miro Miroslavov
Telerik team
answered on 15 Mar 2010, 04:22 PM
Hello GJ DM,

There isn't refresh method that is available for web services. You have to do manually, just on the DipsatcherTimer.Tick handler call your service asynchronously and in the Completed method refresh the grid with the data from the service.
Hope this helps you.

Regards,
Miro Miroslavov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Grtjn
Top achievements
Rank 1
answered on 16 Mar 2010, 08:31 AM
Hi,

Thanks for the reply.
But I am not that familiar with the things you said.
Is there any samplecode available that can help me out ?!

Kind Regards,

Gertjan
0
Grtjn
Top achievements
Rank 1
answered on 19 Mar 2010, 02:07 PM
Can you please explain some more Miro or Vlad.
Because I do need some more help to get this right.

Kind Regards,

Gertjan
0
Milan
Telerik team
answered on 19 Mar 2010, 03:16 PM

Hi GJ DM,

You can simply get the whole data from the web service on every DispatcherTimer tick. 

public MainPage()
{
    InitializeComponent();
  
    DispatcherTimer timer = new DispatcherTimer();
    timer.Interval = TimeSpan.FromMinutes(1);
    timer.Tick += new EventHandler(timer_Tick);
    timer.Start();
}
  
void timer_Tick(object sender, EventArgs e)
{
    // get the whole data
    var updatedData = this.myService.GetData();
    this.myGrid.ItemsSource = updatedData;
}


All the best,
Milan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Grtjn
Top achievements
Rank 1
answered on 23 Mar 2010, 09:25 AM
Hi,

Sorry for the late reply. First of all thanks for sharing this code, but it doesn't seem to work for my...

I get two errors. One on my webservice and one on the itemsSource of my grid.

DispatcherTimer timer = new DispatcherTimer();  
        timer.Interval = TimeSpan.FromSeconds(30);  
        timer.Tick += new EventHandler(timer_Tick);  
        timer.Start();  
        }  
        void timer_Tick(object sender, EventArgs e)  
        {  
            var updatedData = this.WebService.GetData();  
            this.LayoutRoot.ItemsSource = updatedData;  
        } 
Error 1 'Pie_Rad_Trend.MainPage' does not contain a definition for 'WebService' and no extension method 'WebService' accepting a first argument of type 'Pie_Rad_Trend.MainPage' could be found (are you missing a using directive or an assembly reference?) C:\Users\gertjan.demeyer\Documents\Visual Studio 2008\Projects\Pie_Rad_Trend\Pie_Rad_Trend\MainPage.xaml.cs 59 36 Pie_Rad_Trend

Error 2 'System.Windows.Controls.Grid' does not contain a definition for 'ItemsSource' and no extension method 'ItemsSource' accepting a first argument of type 'System.Windows.Controls.Grid' could be found (are you missing a using directive or an assembly reference?) C:\Users\gertjan.demeyer\Documents\Visual Studio 2008\Projects\Pie_Rad_Trend\Pie_Rad_Trend\MainPage.xaml.cs 60 29 Pie_Rad_Trend

Any help?
Also i have the 2009-Q3 version..

Kind regards,

Gertjan
0
Grtjn
Top achievements
Rank 1
answered on 25 Mar 2010, 10:17 AM
You have any idea why this error appears Milan?

Gertjan
0
Grtjn
Top achievements
Rank 1
answered on 29 Mar 2010, 10:31 AM
Plz does anyone know the solution for this?
I really need this timer in order to get my project to work correctly!

Kind regards,

Gertjan
Asked by
Grtjn
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Grtjn
Top achievements
Rank 1
Miro Miroslavov
Telerik team
Milan
Telerik team
Share this question
or