Esempio n. 1
0
        internal short UnRegisterSelectiveCallback(CacheItemRemovedCallback removedCallback)
        {
            if (removedCallback == null)
            {
                return(-1);
            }

            SelectiveRemoveCallbackWrapper callbackWrapper = null;

            // callback is not already registered with the same method, so add
            lock (SyncLockSelective)
            {
                //For selective callback, we dont remove the callback as it can create chaos if user try to unregister
                //a callback more then one time or against wrong items.
                callbackWrapper =
                    (SelectiveRemoveCallbackWrapper)_oldSelectiveCallbackPool.GetResource(removedCallback);

                if (callbackWrapper != null)
                {
                    short[] callbackIds =
                        UnregisterSelectiveNotification(callbackWrapper.MappingCallback, EventType.ItemRemoved);
                    return(callbackIds[1]);
                }

                return(-1);
            }
        }
Esempio n. 2
0
        internal short RegisterSelectiveCallback(CacheItemRemovedCallback removedCallback)
        {
            if (removedCallback == null)
            {
                return(-1);
            }
            lock (SyncLockSelective)
            {
                SelectiveRemoveCallbackWrapper callbackWrapper = null;
                if (_oldSelectiveCallbackPool.GetResource(removedCallback) == null)
                {
                    callbackWrapper = new SelectiveRemoveCallbackWrapper(removedCallback);
                    _oldSelectiveCallbackPool.AddResource(removedCallback, callbackWrapper);
                    _oldSelectiveMappingCallbackPool.AddResource(callbackWrapper, removedCallback);
                }
                else
                {
                    callbackWrapper =
                        (SelectiveRemoveCallbackWrapper)_oldSelectiveCallbackPool.GetResource(removedCallback);
                    _oldSelectiveCallbackPool.AddResource(removedCallback, callbackWrapper);
                }

                short[] callbackIds = RegisterSelectiveEvent(callbackWrapper.MappingCallback, EventType.ItemRemoved,
                                                             EventDataFilter.DataWithMetadata);
                return(callbackIds[1]);
            }
        }