public async static void DequeueTask(object state)
    {
        CancellationToken token = (CancellationToken)state;

        while (!token.IsCancellationRequested)
        {
            if (dequeueSignal.WaitOne())             // block untill we have items in the queue
            {
                NotificationDelivery delivery = null;

                if (deliveryQueue.TryDequeue(out delivery))
                {
                    NotificationDeliveryStatus ns = NotificationDeliveryStatus.Pending;
                    if (delivery.Subscription.Status == SubscriptionStatus.Subscribed)
                    {
                        PushResult result = await PushService.DoPushAsync(delivery);

                        switch (result)
                        {
                        case PushResult.Pushed:
                            ns = NotificationDeliveryStatus.Delivered;
                            break;

                        case PushResult.Error:
                            ns = NotificationDeliveryStatus.FailureError;
                            break;

                        case PushResult.NotSupported:
                            ns = NotificationDeliveryStatus.FailureNotSupported;
                            break;

                        case PushResult.UnSubscribed:
                            ns = NotificationDeliveryStatus.FailureUnSubscribed;
                            delivery.Subscription.Status = SubscriptionStatus.UnSubscribed;
                            break;
                        }
                    }
                    else
                    {
                        ns = NotificationDeliveryStatus.FailureUnSubscribed;
                    }

                    delivery.Status      = ns;
                    delivery.DeliveredAt = DateTime.Now;
                }
                else
                {
                    // empty queue, no more items
                    // stop dequeueing untill new items added by EnqueueTask
                    dequeueSignal.Reset();
                }
            }
        }
    }