Replies: 2 comments 1 reply
-
Currently a single +=/-= operation is implemented in atomic way, with existence check inside it. Can you express your usage with lock statement, so that we can discuss about improving it? |
Beta Was this translation helpful? Give feedback.
-
Broadly to add remove multiple listeners in an atomic transaction.
I am not sure if an existence check is done. There many SO answers which suggest otherwise. E.g. https://stackoverflow.com/questions/136975/has-an-event-handler-already-been-added |
Beta Was this translation helpful? Give feedback.
-
Can API be added so programmers can detect if an function is already added and/or add only if it is not already present.
One can do something like this. But perhaps more performance can be got if there is a way to see if it is already added and / or add if not already added.
Also and atomic way change event / delegate handle (remove old handle if present and add new handle if not already added) would be helpful without using locks. E.g. atomic form of which does not loose events:
This can be extended to multiple atomic removals followed by additions with and without checks to see if the handles are already present.
Beta Was this translation helpful? Give feedback.
All reactions