Esempio n. 1
0
        private void BtnSubscribeClick(object sender, EventArgs e)
        {
            string      dataTypeName;
            IExpression query = BuildExpression(out dataTypeName);

            _client.DebugRequests = chkDebugRequests.Checked;
            ISubscription newSubscription = _client.CreateUntypedSubscription(null, null);

            newSubscription.DataTypeName = dataTypeName;
            newSubscription.WhereExpr    = query;
            newSubscription.UserCallback = delegate(ISubscription subscription, ICoreItem item)
            {
                // note: this is running on a thread pool thread
                // add the item to the queue and post a callback
                _queuedItems.Locked(queue => queue.Enqueue(item));
                int count = Interlocked.Increment(ref _queuedCalls);
                if (count % 10000 == 0)
                {
                    _loggerRef.Target.LogDebug("SubscribeCallback: Queued calls posted: {0}", count);
                }
                _syncContext.Post(ReceiveNewItem, null);
            };
            newSubscription.Start();
            _loggerRef.Target.LogDebug("Subscription started.");
            chkDebugRequests.Checked = false;
        }