//------------------------------------------------------ // // Constructors // //------------------------------------------------------ #region Constructors internal EventListenerClientSide(AutomationElement elRoot, Delegate clientCallback, EventListener l) { _eventListener = l; _refElement = elRoot; // Ensure that RuntimeId is cached on elRoot so that later compares can be done w/o accessing the native element _refRid = elRoot.GetRuntimeId(); _clientCallback = clientCallback; _callbackDelegate = new UiaCoreApi.UiaEventCallback(OnEvent); _gch = GCHandle.Alloc(_callbackDelegate); // }
//------------------------------------------------------ // // Constructors // //------------------------------------------------------ #region Constructors internal EventListenerClientSide(AutomationElement elRoot, Delegate clientCallback, EventListener l) { _eventListener = l; _refElement = elRoot; // Ensure that RuntimeId is cached on elRoot so that later compares can be done w/o accessing the native element _refRid = elRoot.GetRuntimeId(); _clientCallback = clientCallback; _callbackDelegate = new UiaCoreApi.UiaEventCallback(OnEvent); _gch = GCHandle.Alloc(_callbackDelegate); // Note: currently we don't have a well-defined lifetime for the usage of the callback, so don't // really know when to release the GCHandle. Really nead the other event classes to call back to // us when they're done. // For now, just leave _gch to be collected when this object itself is collected. Note that we // don't have a finalizer, since that is only for finalizing non-CLR entities; the GCHandle should // take care of itself. }