Refresh timer

10 posts, 0 answers
  1. Grtjn
    Grtjn avatar
    129 posts
    Member since:
    Feb 2010

    Posted 11 Mar 2010 Link to this post

    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
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 12 Mar 2010 Link to this post

    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.
  3. Grtjn
    Grtjn avatar
    129 posts
    Member since:
    Feb 2010

    Posted 12 Mar 2010 Link to this post

    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
  4. Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 15 Mar 2010 Link to this post

    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.
  5. Grtjn
    Grtjn avatar
    129 posts
    Member since:
    Feb 2010

    Posted 16 Mar 2010 Link to this post

    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
  6. Grtjn
    Grtjn avatar
    129 posts
    Member since:
    Feb 2010

    Posted 19 Mar 2010 Link to this post

    Can you please explain some more Miro or Vlad.
    Because I do need some more help to get this right.

    Kind Regards,

    Gertjan
  7. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 19 Mar 2010 Link to this post

    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.
  8. Grtjn
    Grtjn avatar
    129 posts
    Member since:
    Feb 2010

    Posted 23 Mar 2010 Link to this post

    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
  9. Grtjn
    Grtjn avatar
    129 posts
    Member since:
    Feb 2010

    Posted 25 Mar 2010 Link to this post

    You have any idea why this error appears Milan?

    Gertjan
  10. Grtjn
    Grtjn avatar
    129 posts
    Member since:
    Feb 2010

    Posted 29 Mar 2010 Link to this post

    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
Back to Top