|
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using BusinessApplication1.DataService;
using System.Collections.Generic;
using System.Windows.Threading;
using System.Collections.ObjectModel;
namespace BusinessApplication1.Helpers
{
public class WCFProxy
{
Service1Client svr ;
public void GetData( Action<ObservableCollection<string>,Exception> ac)
{
svr = new Service1Client();
svr.GetListAsync(ac);
svr.GetListCompleted += new EventHandler<GetListCompletedEventArgs>(svr_GetListCompleted);
}
void svr_GetListCompleted(object sender, GetListCompletedEventArgs e)
{
try
{
ObservableCollection<string> str = e.Result as ObservableCollection<string>;
Deployment.Current.Dispatcher.BeginInvoke(
(Action)(() =>
{
(e.UserState as Action<ObservableCollection<string>, Exception>)(str, null);
}));
}
catch (Exception ex)
{
Deployment.Current.Dispatcher.BeginInvoke(
(Action)(() =>
{
(e.UserState as Action<ObservableCollection<string>, Exception>)(null, ex);
}));
}
finally
{
svr.GetListCompleted -= svr_GetListCompleted;
svr.CloseAsync();
svr = null;
}
}
public void GetDataSelected( Action<ObservableCollection<string>,Exception> ac)
{
svr = new Service1Client();
svr.GetSelectedListAsync(ac);
svr.GetSelectedListCompleted += new EventHandler<GetSelectedListCompletedEventArgs>(svr_GetSelectedListCompleted);
}
void svr_GetSelectedListCompleted(object sender, GetSelectedListCompletedEventArgs e)
{
try
{
ObservableCollection<string> str = e.Result as ObservableCollection<string>;
Deployment.Current.Dispatcher.BeginInvoke(
(Action)(() =>
{
(e.UserState as Action<ObservableCollection<string>, Exception>)(str, null);
}));
}
catch (Exception ex)
{
Deployment.Current.Dispatcher.BeginInvoke(
(Action)(() =>
{
(e.UserState as Action<ObservableCollection<string>, Exception>)(null, ex);
}));
}
finally
{
svr.GetSelectedListCompleted -= svr_GetSelectedListCompleted;
svr.CloseAsync();
svr = null;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Microsoft C# MVP (12-13)
Hey, I am Pranay Rana, working as a Team Leadin MNC. Web development in Asp.Net with C# and MS sql server are the experience tools that I have had for the past 5.5 years now.
For me def. of programming is : Programming is something that you do once and that get used by multiple for many years
StackOverFlow - http://stackoverflow.com/users/314488/pranay
My CV :- http://careers.stackoverflow.com/pranayamr
Awards: