Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3335624
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:02:23+00:00 2026-05-18T00:02:23+00:00

I am consuming WCF services from a Silverlight application (MVVM) and windows phone. I

  • 0

I am consuming WCF services from a Silverlight application (MVVM) and windows phone. I have a Service class (Auto-generated) and one IServiceRepository looks like the following

public interface IServiceRepository
{
  event EventHandler<SomeEventArgs> GetDataCompleted;
  void Data GetData();
  // 10 more methods for fetching different data.
}

My SerViceRepository looks like the following

 public class ServiceRepository : IServiceRepository
    {
       public event EventHandler<SomeEventArgs> GetDataCompleted;

       public void Data GetData()
       {
          var proxy = new ActualServiceRefClient();
          proxy.GetDataCompleted += PrivateGetDataCompleted;
          proy.GetDatAsync();
       }

       private void PrivateGetDataCompleted(object s, SomeEventArgs e)
       {
         // Error check and all
         if(GetDataCompleted != null)
            GetDataCompleted(this, new SomeEventArgs(...));
       }
    }

I am calling this methods from my ViewModels. Now my questions are …

  1. Right now I am creating the proxy
    class and attaching event handler
    with it in every method. Should I do
    it in the constructor of
    ServiceRepository? As I said I have
    around 10 to 12 service methods to
    call.
  2. Should I unregister the event handler in the completed method?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:02:24+00:00Added an answer on May 18, 2026 at 12:02 am
    1. I’m not sure it matters where it goes. If you have just one one actual service method you are calling, putting the event wiring in the constructor makes sense. If there is one actual service method for each of the 10 data methods in your service repository, then it makes more sense to have them wired up in each of the 10-12 individual methods.

    2. It depends. If you are keeping an instance of the Service Repository around, making several calls to it, then you should either move the event wiring to the constructor, or make sure you don’t re-wire the event handler on each call. Alternatively, you CAN unregister as you said, but I think it’s best to register those event handlers once for the lifetime of the object. If you are simply creating a new instance of your Service Repository for each can, there is no need to unregister the event handlers.

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Silverlight 2 application that is consuming a WCF service. As such,
I have found 2 ways of consuming a WCF service without the help from
I have a asp mvc application consuming wcf rest services (all on the same
I have a wcf serivce I want to consume from a j2me application (blackberry).
I am consuming a WCF Service from a webpart in Sharepoint 2007. But its
I have an application which consumes a WCF Service. I have no access to
I am consuming a WCF service from a WP7 app. Both are in a
I am consuming a Java Web Service as a WCF service from .NET. The
We've got a WCF service that we're consuming from a web app. The client
I'm consuming a webservice from my application in C# .net (2.0) that return values

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.