?
Solved

silverlight datagrid - WCF Service Data auto refresh

Posted on 2013-01-08
9
Medium Priority
?
1,266 Views
Last Modified: 2013-03-05
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....
0
Comment
Question by:at999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
9 Comments
 
LVL 25

Expert Comment

by:apeter
ID: 38758479
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
 

Author Comment

by:at999
ID: 38759483
can you pl give the code? thanks
0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 2000 total points
ID: 38904853
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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 

Author Comment

by:at999
ID: 38946618
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
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 38946978
since the service call itself is async it shudnt make any diff to the user.
0
 

Author Comment

by:at999
ID: 38951315
thanks a lot
0
 

Author Comment

by:at999
ID: 38951316
i was able to do the way you advised thanks again
0
 
LVL 25

Expert Comment

by:apeter
ID: 38951725
Not even few points for me...idea was mine.
0
 

Author Comment

by:at999
ID: 38955601
oh how did i miss it... i am so sorry apeter,,, next time....
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question