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 602927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:52:33+00:00 2026-05-13T16:52:33+00:00

in my C#-Silverlight-3-Application, I have created a class, that is doing some calculations that

  • 0

in my C#-Silverlight-3-Application, I have created a class, that is doing some calculations that are used in different parts of my program. This class needs data from a database, so it calls a WCF-Service to get the data. The structure of the class looks like this:

public class ConsumptionCalculation
{
  // Declare the event to notify subscribers, that the calculation has finished
  public delegate void HandlerConsumtionCalculationFinished(object sender, ConsumtionCalculationArgs args);
  public event HandlerConsumtionCalculationFinished CalculationFinished;

  public void Do(int id)
  {
    // call the WCF-Service
    DataContainer.instance.dataSource.GetConsumtionInfoAsync(id);
  }

  void dataSource_GetConsumtionInfoCompleted(object sender, GetConsumtionInfoCompletedEventArgs e)
  {
    // Receive the result of the WCF-Service call
    // do some calculation here and put the results in the variable 'args'

    // Raise an event to notify listeners, that the calculation is finished
    CalculationFinished(this, args);
  }
}

The objects that need the calculation-class reference it and subscribe to the CalculationFinished event.

public class IUseTheCalculation
{
  ConsumptionCalculation _calcObject;

  public IUseTheCalculation()
  {
    _calcObject = new ConsumptionCalculation();
    _calcObject.CalculationFinished += new HandlerConsumptionCalculationFinished(CalculationFinishedEvent);
  }

  private void CalculationFinishedEvent(object sender, ConsumptionCalculationArgs args)
  {
    // use the calculation to display data or write it to a file or whatever
  }
}

I have more than one class like the IUseTheCalculation class that each have their own ConsumptionCalculation-Object.

My problem is the following:
When I call the Do-method of the ConsumptionCalculation-object in one of the classes, ALL classes, that have a reference to any ConsumptionCalculation-object will receive the resulting CalculationFinished event. I think this is because all existing ConsuptionCalculation-objects recieve the dataSource_GetConsumtionInfoCompleted event from the WCF-Service.
But I want only the calling object to receive the event. I guess there is a standard approach to this kind of problem, but I couldn’t figure it out yet. How would you resolve this problem?

Thanks in advance,
Frank

  • 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-13T16:52:33+00:00Added an answer on May 13, 2026 at 4:52 pm

    You didn’t show where or how you declare the CalculationFinished event. If it were static, that would explain the behavior you’re seeing. But I’ll assume you already checked that. Perhaps in the debugger you could examine the objects in question to determine if they are actually diffenent instances, as you are assuming they are.

    Could you use the “id” field to distinguish the various callers (and if not, perhaps add an additional parameter to do so)? This wouldn’t stop the other classes from getting notified, but they could all check quickly to see if the notification is for them, and return quickly if not.

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

Sidebar

Related Questions

I have to create a publish-subscribe silverlight application. and the class that publishes the
I have a Silverlight application that is built from a set of Silverlight class
I have created a Windows Phone 7.5 Silverlight application. Most of the design and
I have created a new silverlight business application in visual studio. It auto generates
I have created a web application with a Silverlight project embedded in it, using
Visual Studio 2010 RC -> Silverlight Application We have a library of images that
I have an ASP MVC application which uses some silverlight applications in the View.
I have a Silverlight application that uses WCF services and also uses the Wintellect
I am fairly new to Silverlight. I have an application I'm working on that
Using VS2008, Silverlight 4. I have created an AttachedProperty, RequiresRole, that I'm setting in

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.