public async Task StopReceiver(TimeSpan waitTime)
{
// 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(waitTime);
await this.subscriptionClient.CloseAsync();
var manager = NamespaceManager.CreateFromConnectionString(this.serviceBusConnectionString);
if (await manager.TopicExistsAsync(this.topicName))
{
try
{
await manager.DeleteTopicAsync(this.topicName);
}
catch (MessagingEntityNotFoundException)
{
Trace.TraceWarning(
"MessagingEntityNotFoundException Deleting Topic - Topic does not exist at path: {0}", this.topicName);
}
}
}