Solved

silverlight datagrid - WCF Service Data auto refresh

Posted on 2013-01-08
9
1,247 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 94
JSON JavaScript object notation usage 4 100
Dir function fails on mapped drives 28 123
Need a complete list of ASP.NET page load events 3 26
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now