Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient.CreateTopicAsync C# (CSharp) Method

CreateTopicAsync() public method

Initiates the asynchronous execution of the CreateTopic operation.
public CreateTopicAsync ( CreateTopicRequest request, CreateTopicResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void
request Amazon.SimpleNotificationService.Model.CreateTopicRequest Container for the necessary parameters to execute the CreateTopic operation on AmazonSimpleNotificationServiceClient.
callback CreateTopicResponse>.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 CreateTopicAsync(CreateTopicRequest request, AmazonServiceCallback<CreateTopicRequest, CreateTopicResponse> callback, AsyncOptions options = null)
        {
            options = options == null?new AsyncOptions():options;
            var marshaller = new CreateTopicRequestMarshaller();
            var unmarshaller = CreateTopicResponseUnmarshaller.Instance;
            Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
            if(callback !=null )
                callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
                    AmazonServiceResult<CreateTopicRequest,CreateTopicResponse> responseObject 
                            = new AmazonServiceResult<CreateTopicRequest,CreateTopicResponse>((CreateTopicRequest)req, (CreateTopicResponse)res, ex , ao.State);    
                        callback(responseObject); 
                };
            BeginInvoke<CreateTopicRequest>(request, marshaller, unmarshaller, options, callbackHelper);
        }

Same methods

AmazonSimpleNotificationServiceClient::CreateTopicAsync ( CreateTopicRequest request, System cancellationToken = default(CancellationToken) ) : Task
AmazonSimpleNotificationServiceClient::CreateTopicAsync ( string name, System cancellationToken = default(CancellationToken) ) : Task
AmazonSimpleNotificationServiceClient::CreateTopicAsync ( string name, CreateTopicResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void

Usage Example

コード例 #1
0
 /// <summary>
 /// Ensures the topic. The call to create topic is idempotent and just returns the arn if it already exists. Therefore there is 
 /// no nee to check then create if it does not exist, as this would be extral calls
 /// </summary>
 /// <param name="topicName">Name of the topic.</param>
 /// <param name="client">The client.</param>
 /// <returns>System.String.</returns>
 private string EnsureTopic(string topicName, AmazonSimpleNotificationServiceClient client)
 {
     _logger.Value.DebugFormat("Topic with name {0} does not exist. Creating new topic", topicName);
     var topicResult = client.CreateTopicAsync(new CreateTopicRequest(topicName)).Result;
     return topicResult.HttpStatusCode == HttpStatusCode.OK ? topicResult.TopicArn : string.Empty;
 }
AmazonSimpleNotificationServiceClient