Is there a way to determine if an event listener has already been created with a RowCreatedEvent (or Deleted, Changed)?

476
4
08-09-2019 08:05 AM
FrankMartin1
New Contributor III

I've created an add in button that subscribes to a RowChangedEvent for each layer in a map.    If another layer is added to the map and the add in button is executed again,  each of the previous layers that already were subscribed will now have an additional event listener.  Is there a way to determine if an event listener (RowChangedEvent) is already associated with a layer so I can prevent a additional ones from being created?

Thanks for your help!

Frank

Tags (1)
0 Kudos
4 Replies
KoryKramer
Esri Community Moderator

Is this an ArcGIS Pro SDK‌ question?

0 Kudos
FrankMartin1
New Contributor III

Sorry. Yes, it’s an ArcGIS Pro SDK question.

by Anonymous User
Not applicable

Hi Frank,

There's nothing currently in the public API you can use to determine if a layer has an associated event.

You could maintain a collection (list or dictionary) of layers that have been subscribed to and check the list when iterating through the map layers again. Use the Layer.URI property to ensure uniqueness.

FrankMartin1
New Contributor III

Thanks, Sean.   I  thought that might be the case.  I'll give the collection a try.

Thanks again,

Frank  

0 Kudos