What are the purpose of delegate handles?

They are simply ID’s for a specific binding. They can be used to remove bindings by their unique ID instead of by object/function name etc. Really it’s just a wrapper for an “int” counter belonging to a given delegate instance.

Note that Delegate Handles only exist on non-dynamic delegates and cannot be serialized.

Here’s an example use of them:

Note that when you “remove” a delegate, the handle you pass in is not invalidated. If you want to reuse a handle after removal, you must reset it yourself.

1 Like