コード例 #1
0
        public void RegisterUpdateNotification(ContinuousQueryItemUpdatedCallback itemUpdatedCallback)
        {
            if (itemUpdatedCallback != null)
            {
                _itemUpdated += itemUpdatedCallback;

                lock (syncLock)
                {
                    if (++refupdate == 1)
                    {
                        updateCallback =
                            new QueryDataNotificationCallback(_notificationsWrapper.OnQueryChangeNotifiation);
                        this.RegisterNotification(updateCallback, EventType.ItemUpdated, EventDataFilter.None);
                    }
                }
            }
            else
            {
                _itemUpdated = null;

                lock (syncLock)
                {
                    if (refupdate > 0)
                    {
                        refupdate = 0;
                        this.UnRegisterNotification(updateCallback, EventType.ItemUpdated);
                    }
                }
            }
        }
コード例 #2
0
        internal void OnItemUpdated(string key, bool notifyAsync)
        {
            if (_itemUpdated != null)
            {
                Delegate[] dltList = _itemUpdated.GetInvocationList();
                for (int i = dltList.Length - 1; i >= 0; i--)
                {
                    ContinuousQueryItemUpdatedCallback subscriber = (ContinuousQueryItemUpdatedCallback)dltList[i];

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

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