Exemple #1
0
        private void ThreadHandler(object o)
        {
            try
            {
                while (GetEventsCountLocked() > 0)
                {
                    var operation = _database.NextOperation();

                    switch (operation)
                    {
                    case IscCodes.op_response:
                        _database.ReadResponse();
                        continue;

                    case IscCodes.op_exit:
                    case IscCodes.op_disconnect:
                        Close();
                        return;

                    case IscCodes.op_event:
                        var dbHandle = _database.ReadInt32();
                        var buffer   = _database.ReadBuffer();
                        var ast      = _database.ReadBytes(8);
                        var eventId  = _database.ReadInt32();

                        RemoteEvent currentEvent;
                        if (_events.TryRemove(eventId, out currentEvent))
                        {
                            // Notify new event counts
                            currentEvent.EventCounts(buffer);
                        }

                        continue;
                    }
                }
            }
            catch (ThreadAbortException)
            {
                return;
            }
            catch
            {
                return;
            }
        }