1
listener.StatisticValueUpdated += (sender, e) =>
{ 
    if (e.StatisticValues.Count > 0)
    {
        StatisticValue statValue = e.StatisticValues[0];
        ReadOnlyCollection<StatisticKey> key = e.StatisticKeys;

        if (!statValue.IsError && !statValue.IsNull)
        {
            //work with stat                 
        }
     }
};

What I have tried: -Created a lamda expression to have access to other variables.

I currently have a listener in which I need to keep track of statistics. Each statistic has a statistic as well as a campaign. I am using an API so I cannot customize the "EventArgs". I basically need a Unique Identifier for each listener. How can I accomplish this?

EDIT: What I ended up doing was creating a base class aggregate and wrapped each statistics with their given parameter set.

Rob
  • 53
  • 1
  • 9
  • Add the Id to the Listener class, and then access it via the `sender` parameter? – stuartd Jul 22 '16 at 14:42
  • I am using an API. It would be much easier if I had access to the source, but unfortunately I do not. – Rob Jul 22 '16 at 14:46
  • You could give [`RuntimeHelpers.GetHashCode(sender as Listener)`](https://msdn.microsoft.com/en-us/library/11tbk3h9(v=vs.110).aspx) a try [(reference)](http://stackoverflow.com/questions/750947/net-unique-object-identifier) – stuartd Jul 22 '16 at 14:51
  • And/or the [ObjectIDGenerator](https://msdn.microsoft.com/en-us/library/system.runtime.serialization.objectidgenerator.aspx) [(reference)](http://stackoverflow.com/questions/9788680/how-do-i-obtain-an-id-that-allows-me-to-tell-difference-instances-of-a-class-apa) – stuartd Jul 22 '16 at 14:53
  • The RuntimeHelper recommended usage of ReferenceEquals(obj A, obj B). I tried that it didn't seem to work. I will check out that Obj ID Gen. – Rob Jul 22 '16 at 15:11

0 Answers0