silverlight datagrid - WCF Service Data auto refresh

i have silverlight page, it has a datagrid. I have created a WCF service  which generates data for that datagrid. In my silverlight page, i call that service as shown below


                MyService.MyServiceClient mysvcclient1;
                mysvcclient1= new  MyService.MyServiceClient();
                mysvcclient1.GetDataGridDataCompleted += new EventHandler<MyService.GetDataGridDataCompletedEventArgs>(CompletedHereGetDataGrid);
                mysvcclient1.GetDataGridDataAsync();
                mysvcclient1.CloseAsync();
            }

now i want to refresh that data every 30 seconds... what is the best way to do that?


thanks....
at999Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Gautham JanardhanConnect With a Mentor Commented:
this shud do the trick

public partial class MainPage : UserControl
    {
        DispatcherTimer tmr;

        public MainPage()
        {
            InitializeComponent();
            TimerInit();
            CallService();
        }

        private void TimerInit()
        {
            tmr = new DispatcherTimer();
            tmr.Interval = TimeSpan.FromSeconds(30);
            tmr.Tick += delegate
            {
                CallService();
            };
        }

        private void CallService()
        {
            tmr.Stop();
            MyService.MyServiceClient mysvcclient1;
            mysvcclient1 = new MyService.MyServiceClient();
            mysvcclient1.GetDataGridDataCompleted += new EventHandler<MyService.GetDataGridDataCompletedEventArgs>(CompletedHereGetDataGrid);
            mysvcclient1.GetDataGridDataAsync();
        }

        public void CompletedHereGetDataGrid.........
        {
            tmr.Start();
        }
    }

Open in new window

0
 
apeterCommented:
Have a Timer in silverlight and refresh your datagrid.

1. When making call , stop the timer.
2. When the async call comes back , start the timer.
0
 
at999Author Commented:
can you pl give the code? thanks
0
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
at999Author Commented:
thanks so much gauthampj, will my GUI be stuck when i start DispatcherTimer ? i mean if i start DispatcherTimer will user be able to click other buttons on my silverlight page? please help,,,, many thanks
0
 
Gautham JanardhanCommented:
since the service call itself is async it shudnt make any diff to the user.
0
 
at999Author Commented:
thanks a lot
0
 
at999Author Commented:
i was able to do the way you advised thanks again
0
 
apeterCommented:
Not even few points for me...idea was mine.
0
 
at999Author Commented:
oh how did i miss it... i am so sorry apeter,,, next time....
0
All Courses

From novice to tech pro — start learning today.