Exemple #1
0
        private void OptimisticQueuing(DroneEvent droneEvent, CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested)
            {
                var eventQueue = _eventQueue;
                var original   = Interlocked.CompareExchange(
                    ref _eventQueue,
                    eventQueue.Enqueue(droneEvent),
                    eventQueue);

                if (object.ReferenceEquals(eventQueue, original))
                {
                    return;
                }
            }
        }
Exemple #2
0
 protected void OnNewEvent(DroneEvent data)
 {
     NewEvent?.Invoke(this, data);
 }