Solved

silverlight datagrid - WCF Service Data auto refresh

Posted on 2013-01-08
9
1,253 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
  • 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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…

777 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