public async Task Close(TimeSpan timespan)
        {
            // Pause the processing threads
            this.pauseProcessingEvent.Reset();

            // There is no clean approach to wait for the threads to complete processing.
            //  We simply stop any new processing, wait for existing thread to complete, then close the message pump and then return
            Thread.Sleep(timespan);

            this.inQueue.Close();

            // Cleanup resources.
            await ServiceBusUtilities.DeleteQueueIfExistsAsync(Settings.ServiceBusConnectionString, this.inQueue.Path);
        }
コード例 #2
0
        public async Task Stop(TimeSpan?waitTime)
        {
            if (waitTime.HasValue)
            {
                // Pause the processing threads on the message pump.
                this.pauseProcessingEvent.Reset();

                // There is no clean approach to wait for the threads to complete processing.
                // We simply stop any new processing, wait for existing thread to complete, then close the message pump and then return
                Thread.Sleep(waitTime.Value);
            }

            await this.client.CloseAsync();

            await ServiceBusUtilities.DeleteQueueIfExistsAsync(this.connectionString, this.queueName);
        }
        public void Start()
        {
            // Create the inbound filter queue if it does not exist
            var createInQueueTask = ServiceBusUtilities.CreateQueueIfNotExistsAsync(this.connectionString, this.inQueuePath);

            // Create the outbound filter queue if it does not exist
            if (!string.IsNullOrEmpty(outQueuePath))
            {
                ServiceBusUtilities.CreateQueueIfNotExistsAsync(this.connectionString, this.outQueuePath).Wait();

                this.outQueue = QueueClient.CreateFromConnectionString(this.connectionString, this.outQueuePath);
            }

            // Wait for queue creations to complete
            createInQueueTask.Wait();

            // Create inbound and outbound queue clients
            this.inQueue = QueueClient.CreateFromConnectionString(this.connectionString, this.inQueuePath);
        }