Solved

silverlight datagrid - WCF Service Data auto refresh

Posted on 2013-01-08
9
1,263 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 500 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

636 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