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

PurgeQueueAsync() public method

Initiates the asynchronous execution of the PurgeQueue operation.
public PurgeQueueAsync ( PurgeQueueRequest request, PurgeQueueResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void
request Amazon.SQS.Model.PurgeQueueRequest Container for the necessary parameters to execute the PurgeQueue operation on AmazonSQSClient.
callback PurgeQueueResponse>.AmazonServiceCallback An Action delegate that is invoked when the operation completes.
options Amazon.Runtime.AsyncOptions A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.
return void
        public void PurgeQueueAsync(PurgeQueueRequest request, AmazonServiceCallback<PurgeQueueRequest, PurgeQueueResponse> callback, AsyncOptions options = null)
        {
            options = options == null?new AsyncOptions():options;
            var marshaller = new PurgeQueueRequestMarshaller();
            var unmarshaller = PurgeQueueResponseUnmarshaller.Instance;
            Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
            if(callback !=null )
                callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
                    AmazonServiceResult<PurgeQueueRequest,PurgeQueueResponse> responseObject 
                            = new AmazonServiceResult<PurgeQueueRequest,PurgeQueueResponse>((PurgeQueueRequest)req, (PurgeQueueResponse)res, ex , ao.State);    
                        callback(responseObject); 
                };
            BeginInvoke<PurgeQueueRequest>(request, marshaller, unmarshaller, options, callbackHelper);
        }

Same methods

AmazonSQSClient::PurgeQueueAsync ( PurgeQueueRequest request, System cancellationToken = default(CancellationToken) ) : Task
AmazonSQSClient::PurgeQueueAsync ( string queueUrl, System cancellationToken = default(CancellationToken) ) : Task
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