c# - Restricting asynchronous events to the calling object -
In my C # -Cylverlight-3-application, I have created a square, which calculates something that is different Parts of My Program This section requires data from a database, so it calls the WCF service to receive the data. The structure of the class looks like this:
Public class Consumption Clarity {// Announce the event to inform the subscribers, that the calculation is finished to the public representative HandlerConsumtionCalculationFinished (object sender, ConsumtionCalculationArgs args); Public event handlerusation evaluationfinished calculationsfinnished; Public Zero (int ID) {// call WCF-Service DataContainer.instance.dataSource.GetConsumtionInfoAsync (ID); } Get zero results of zero data SOURCE_GetConsumtionInfoCompleted (Object Sender, GetConsumtionInfoCompletedEventArgsE) {// WCF- service call // Here do some calculations and put in results 'extreme' // Increase an event to inform listeners, calculate that Calculation has ended (this, args); }}
Objects require references to the calculating class and subscribes to calculation finite events.
Public Segment IUseTheCalculation {ConsumptionCalculation _calcObject; Public IUseTheCalculation () {_calcObject = New Consumption (); _calcObject.CalculationFinished + = New Handler Consumption ClinicsFinished (calculatedfile events); } Private Vain Calculation Finalized Event (Object Sender, ConsumptionAlgance Elgies) {// To display the data or to write it in the file, Calculation or any object}}
I have more than one Class IUseTheCalculation Each person's own consumption is Clalligen-Object.
My problem is as follows: When I call the methodology of consumption clallis object in one of the classes, then all the classes, which are in reference to any Consumption Clalgmentation Object, The calculationfininated event will be received. I think this is because all existing Consolidation Client-Objects receive Datasource_GetConsent Infos. All events from WCF-Service But I want only calling object to get the event. I think there is a standard approach to this kind of problem, but I could not understand it yet. How do you solve this problem?
Thank you in advance, Frank
You will not say that you have made a calculation When or how to declare it. If it was static, then it would explain the behavior that you are seeing. But I think you have already checked it. Perhaps in the debugger you can check the objects to determine if there are actually different examples, because you believe they are.
Can you use the "id" field to separate different callers (and no, maybe add an extra parameter to do this)? It can not prevent other classes from being notified, but they can all quickly check whether there is a notification for them, and if not hurry then return.
Comments
Post a Comment