예제 #1
0
 public void CancelEvents()
 {
     _db.CancelEvents(this);
     _currentCounts  = null;
     _previousCounts = null;
     _events.Clear();
     Volatile2.Write(ref _running, 0);
 }
예제 #2
0
        internal void EventCounts(byte[] buffer)
        {
            if (Volatile2.Read(ref _running) == 0)
            {
                return;
            }

            _previousCounts = _currentCounts;
            _currentCounts  = new int[_events.Count];

            var pos = 1;

            while (pos < buffer.Length)
            {
                var length    = buffer[pos++];
                var eventName = _charset.GetString(buffer, pos, length);

                pos += length;

                var index = _events.IndexOf(eventName);
                if (index == -1)
                {
                    Debugger.Break();
                }
                Debug.Assert(index != -1);
                _currentCounts[index] = BitConverter.ToInt32(buffer, pos) - 1;

                pos += 4;
            }

            for (var i = 0; i < _events.Count; i++)
            {
                var count = _currentCounts[i] - _previousCounts[i];
                if (count == 0)
                {
                    continue;
                }
                EventCountsCallback(_events[i], count);
            }

            QueueEventsImpl();
        }