Amazon.SQS.AmazonSQSClient.PurgeQueueAsync C# (CSharp) Method

PurgeQueueAsync() public method

Initiates the asynchronous execution of the PurgeQueue operation.
public PurgeQueueAsync ( PurgeQueueRequest request, System cancellationToken = default(CancellationToken) ) : Task
request Amazon.SQS.Model.PurgeQueueRequest Container for the necessary parameters to execute the PurgeQueue operation.
cancellationToken System /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. ///
return Task
        public Task<PurgeQueueResponse> PurgeQueueAsync(PurgeQueueRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new PurgeQueueRequestMarshaller();
            var unmarshaller = PurgeQueueResponseUnmarshaller.Instance;

            return InvokeAsync<PurgeQueueRequest,PurgeQueueResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }

Same methods

AmazonSQSClient::PurgeQueueAsync ( string queueUrl, System cancellationToken = default(CancellationToken) ) : Task
AmazonSQSClient::PurgeQueueAsync ( PurgeQueueRequest request, PurgeQueueResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void
AmazonSQSClient::PurgeQueueAsync ( string queueUrl, PurgeQueueResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void

Usage Example

Example #1
0
        /// <summary>
        /// Purges the specified queue name.
        /// </summary>
        public void Purge()
        {
            try
            {
                using (var client = new AmazonSQSClient(_credentials))
                {
                    _logger.Value.InfoFormat("SqsMessageConsumer: Purging the queue {0}", _queueUrl);

                    client.PurgeQueueAsync(_queueUrl).Wait();

                    _logger.Value.InfoFormat("SqsMessageConsumer: Purged the queue {0}", _queueUrl);
                }
            }
            catch (Exception exception)
            {
                _logger.Value.ErrorException("SqsMessageConsumer: Error purging queue {0}", exception, _queueUrl);
                throw;
            }
        }
AmazonSQSClient