Exemplo n.º 1
0
        public void Start(CancellationToken cancellationToken)
        {
            var storageAccount = CloudStorageAccount.Parse(connectionString);
            var container      = storageAccount.CreateCloudBlobClient().GetContainerReference(delayedDeliveryTable.Name);

            lockManager = new LockManager(container, LeaseLength);

            // No need to pass token to run. to avoid when token is canceled the task changing into
            // the canceled state and when awaited while stopping rethrow the canceled exception
            delayedMessagesPollerTask = Task.Run(() => Poll(cancellationToken), CancellationToken.None);
        }
        public void Start(CancellationToken cancellationToken = default)
        {
            Logger.Debug("Starting delayed message poller");

            var containerClient = blobServiceClient.GetBlobContainerClient(delayedDeliveryTable.Name);
            var leaseClient     = new BlobLeaseClient(containerClient);

            lockManager = new LockManager(containerClient, leaseClient, LeaseLength);

            pollerCancellationTokenSource = new CancellationTokenSource();

            // Task.Run() so the call returns immediately instead of waiting for the first await or return down the call stack
            delayedMessagesPollerTask = Task.Run(() => PollAndSwallowExceptions(pollerCancellationTokenSource.Token), CancellationToken.None);
        }