Example #1
0
        public void RegisterRemoveNotification(ContinuousQueryItemRemovedCallback itemRemovedCallback)
        {
            if (itemRemovedCallback != null)
            {
                _itemRemoved += itemRemovedCallback;

                lock (syncLock)
                {
                    if (++refremove == 1)
                    {
                        removeCallback =
                            new QueryDataNotificationCallback(_notificationsWrapper.OnQueryChangeNotifiation);
                        this.RegisterNotification(removeCallback, EventType.ItemRemoved,
                                                  EventDataFilter.DataWithMetadata);
                    }
                }
            }
            else
            {
                _itemRemoved = null;

                lock (syncLock)
                {
                    if (refremove > 0)
                    {
                        refremove = 0;
                        this.UnRegisterNotification(removeCallback, EventType.ItemRemoved);
                    }
                }
            }
        }
Example #2
0
        internal void OnItemRemoved(string key, bool notifyAsync)
        {
            if (_itemRemoved != null)
            {
                Delegate[] dltList = _itemRemoved.GetInvocationList();
                for (int i = dltList.Length - 1; i >= 0; i--)
                {
                    ContinuousQueryItemRemovedCallback subscriber = (ContinuousQueryItemRemovedCallback)dltList[i];

                    try
                    {
                        if (notifyAsync)
                        {
#if !NETCORE
                            subscriber.BeginInvoke(key, new System.AsyncCallback(ItemRemovedAsyncCallbackHandler),
                                                   subscriber);
#elif NETCORE
                            TaskFactory factory = new TaskFactory();
                            Task        task    = factory.StartNew(() => subscriber(key));
#endif
                        }
                        else
                        {
                            subscriber(key);
                        }
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
        }
Example #3
0
        private void ItemRemovedAsyncCallbackHandler(IAsyncResult ar)
        {
            ContinuousQueryItemRemovedCallback subscribber = (ContinuousQueryItemRemovedCallback)ar.AsyncState;

            try
            {
                subscribber.EndInvoke(ar);
            }
            catch (Exception e)
            {
            }
        }