how do i centralize service calls in another class and get the result back ?

Hi,
I have a silverlight application that has to call services (WCF). Now I don't want to fill up my code-behind with stuff like this, but i want to centralize all my service calls in another class.
I know how to call a method in that other class that does the async call of the webservice. The webservice call completed event is also put in that class. But now I don't know how to get that info (result of the service call) back in my code behind file.
Can somebody show me an example ?
ippeterAsked:
Who is Participating?
 
puru1981Connect With a Mentor Commented:
because event should be always handled through controller and notified to view.
0
 
puru1981Commented:
make a service layer which consist of proxies of the WCF services.

then use them in your code behind.
0
 
ippeterAuthor Commented:
Hi pure1981,
what is a service layer ? And how to make it ?
Maybe an example or a link to more info on this ?

thanks,
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
puru1981Commented:
i mean that is a central place where all the service related configuration will sit. It is parallel to your BAL.

this will be a new project which will handle all the service related activities.
0
 
ippeterAuthor Commented:
I understand what you explain, but there is still one more thing i don't know how to do it.
When i call the other project who does the service stuff, how do i know when the service is completed.
Now i do the service calls in my code behind and i can handle the result immediately in the UI.
ex of how i do it now:
private void GetStatus()
{
            Max200Client proxi = new Max200Client();
             // Attach an event handler to the completed event
             proxi.GetStatusCompleted += new EventHandler<GetStatusCompletedEventArgs>(proxi_GetStatusCompleted);
                 // Start the web service call
                proxi.GetStatusAsync(statusLijstUniversal, statusLijstAudio, statusLijstTemp);
}

void proxi_GetStatusCompleted(object sender, GetStatusCompletedEventArgs e)
{
       // in here i can handle the result and fill in the UI.
}

But how do i know when the GetStatusCompleted event is done when i put this stuff in another project ? My webpage has to continue working, but when the Status is arrived sereral things has to update.
Hope you understand my issue here.
0
 
puru1981Commented:
in that case i don't think you have choice.

0
All Courses

From novice to tech pro — start learning today.