当前位置: 首页>>代码示例>>C#>>正文


C# Runtime.AsyncOptions类代码示例

本文整理汇总了C#中Amazon.Runtime.AsyncOptions的典型用法代码示例。如果您正苦于以下问题:C# AsyncOptions类的具体用法?C# AsyncOptions怎么用?C# AsyncOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AsyncOptions类属于Amazon.Runtime命名空间,在下文中一共展示了AsyncOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PostObjectAsync

        /// <summary>
        /// Upload data to Amazon S3 using HTTP POST.
        /// </summary>
        /// <remarks>
        /// For more information, <see href="http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingHTTPPOST.html"/>
        /// </remarks>
        /// <param name="request">Request object which describes the data to POST</param>
        /// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
        /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        public void PostObjectAsync(PostObjectRequest request, AmazonServiceCallback<PostObjectRequest, PostObjectResponse> callback, AsyncOptions options = null)
        {
            options = options == null ? new AsyncOptions() : options;

            Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper
                = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) =>
                {
                    AmazonServiceResult<PostObjectRequest, PostObjectResponse> responseObject
                        = new AmazonServiceResult<PostObjectRequest, PostObjectResponse>((PostObjectRequest)req, (PostObjectResponse)res, ex, ao.State);
                    if (callback != null)
                        callback(responseObject);
                };

            ThreadPool.QueueUserWorkItem(new WaitCallback(delegate
            {
                // Provide a default policy if user doesn't set it.
                try
                {
                    InferContentType(request);
                    if (request.SignedPolicy == null)
                    {
                        CreateSignedPolicy(request);
                    }
                    PostObject(request, options, callbackHelper);
                }
                catch (Exception e)
                {
                    callback(new AmazonServiceResult<PostObjectRequest, PostObjectResponse>(request, null, e, options.State));
                }
            }));

        }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:42,代码来源:AmazonS3Client.unity.cs

示例2: AsyncExecutor

 public static void AsyncExecutor(Action action, AsyncOptions options)
 {
     if (options.ExecuteCallbackOnMainThread)
     {
         if (UnityInitializer.IsMainThread())
         {
             SafeExecute(action);
         }
         else
         {
             UnityRequestQueue.Instance.ExecuteOnMainThread(action);
         }
     }
     else
     {
         if (!UnityInitializer.IsMainThread())
         {
             SafeExecute(action);
         }
         else
         {
             ThreadPool.QueueUserWorkItem((state) =>
             {
                 SafeExecute(action);
             });
         }
     }
 }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:28,代码来源:InternalSDKUtils.unity.cs

示例3: LoadTableAsync

 internal static void LoadTableAsync(IAmazonDynamoDB ddbClient, string tableName, Table.DynamoDBConsumer consumer, DynamoDBEntryConversion conversion, AmazonDynamoDBCallback<Table> callback, AsyncOptions asyncOptions = null)
 {
     asyncOptions = asyncOptions??new AsyncOptions();
     DynamoDBAsyncExecutor.ExecuteAsync<Table>(
     ()=>{
         return LoadTable(ddbClient,tableName,consumer,conversion);
     },asyncOptions,callback);
 }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:8,代码来源:Table.Async.cs

示例4: GetRemainingAsync

 /// <summary>
 /// Initiates the asynchronous execution of the GetRemaining operation.
 /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.Search.GetRemaining"/>
 /// </summary>        
 /// <param name="callback">The callback that will be invoked when the asynchronous operation completes.</param> 
 /// <param name="asyncOptions">An instance of AsyncOptions that specifies how the async method should be executed.</param>
 public void GetRemainingAsync(AmazonDynamoDBCallback<List<Document>> callback, AsyncOptions asyncOptions = null)
 {
     asyncOptions = asyncOptions ?? new AsyncOptions();
     DynamoDBAsyncExecutor.ExecuteAsync<List<Document>>(
         () => { return GetRemainingHelper(true); },
         asyncOptions,
         callback);
 }
开发者ID:NathanSDunn,项目名称:aws-sdk-unity,代码行数:14,代码来源:Search.Async.cs

示例5: ExecuteAsync

 /// <summary>
 /// Initiates the asynchronous execution of the Execute operation.
 /// <seealso cref="Amazon.DynamoDBv2.DataModel.MultiTableBatchWrite.Execute"/>
 /// </summary>        
 /// <param name="callback">The callback that will be invoked when the asynchronous operation completes.</param>
 /// <param name="asyncOptions">An instance of AsyncOptions that specifies how the async method should be executed.</param>
 public void ExecuteAsync(AmazonDynamoDBCallback callback, AsyncOptions asyncOptions = null)
 {
     asyncOptions = asyncOptions ?? new AsyncOptions();
     DynamoDBAsyncExecutor.ExecuteAsync(
         () => { ExecuteHelper(true); },
         asyncOptions,
         callback);
 }
开发者ID:paveltimofeev,项目名称:aws-sdk-unity,代码行数:14,代码来源:BatchWrite.Async.cs

示例6: PutItemAsync

 /// <summary>
 /// Initiates the asynchronous execution of the PutItem operation.
 /// </summary>
 /// <param name="doc">Document to save.</param>        
 /// <param name="callback">The callback that will be invoked when the asynchronous operation completes.</param> 
 /// <param name="asyncOptions">An instance of AsyncOptions that specifies how the async method should be executed.</param>
 public void PutItemAsync(Document doc, AmazonDynamoDBCallback<Document> callback, AsyncOptions asyncOptions = null)
 {
     asyncOptions = asyncOptions ?? new AsyncOptions();
     DynamoDBAsyncExecutor.ExecuteAsync<Document>(
         () => { return PutItemHelper(doc, null, true); },
         asyncOptions,
         callback);
 }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:14,代码来源:Table.Async.cs

示例7: SynchronizeAsync

        /// <summary>
        /// Synchronize <see cref="Dataset"/> between local storage and remote storage.
        /// </summary>
        public virtual void SynchronizeAsync(AsyncOptions options = null)
        {
            options = options == null ? new AsyncOptions() : options;
            if (_netReachability.NetworkStatus == NetworkStatus.NotReachable)
            {
                FireSyncFailureEvent(new NetworkException("Network connectivity unavailable."), options);
                return;
            }

            SynchronizeHelperAsync(options);
        }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:14,代码来源:Dataset.unity.cs

示例8: DownloadToAsync

 /// <summary>
 /// Initiates the asynchronous execution of the DownloadTo operation.
 /// </summary>
 /// <param name="downloadPath">Path to save the file.</param>
 /// <param name="callback">The callback that will be invoked when the asynchronous operation completes.</param> 
 /// <param name="asyncOptions">An instance of AsyncOptions that specifies how the async method should be executed.</param>
 public void DownloadToAsync(string downloadPath, AmazonDynamoDBCallback callback, AsyncOptions asyncOptions = null)
 {
     asyncOptions = asyncOptions ?? new AsyncOptions();
     DynamoDBAsyncExecutor.ExecuteAsync(
         () =>
         {
             this.s3ClientCache.GetClient(this.RegionAsEndpoint).DownloadToFilePath(
         this.linker.s3.bucket, this.linker.s3.key, downloadPath, null);
         },
         asyncOptions,
         callback);
 }
开发者ID:johnryork,项目名称:aws-sdk-unity,代码行数:18,代码来源:S3Link.Async.cs

示例9: UploadFromAsync

 /// <summary>
 /// Initiates the asynchronous execution of the UploadFrom operation.
 /// </summary>
 /// <param name="sourcePath">Path of the file to be uploaded.</param>        
 /// <param name="callback">The callback that will be invoked when the asynchronous operation completes.</param> 
 /// <param name="asyncOptions">An instance of AsyncOptions that specifies how the async method should be executed.</param>
 public void UploadFromAsync(string sourcePath, AmazonDynamoDBCallback callback, AsyncOptions asyncOptions = null)
 {
     asyncOptions = asyncOptions ?? new AsyncOptions();
     DynamoDBAsyncExecutor.ExecuteAsync(
         () =>
         {
             this.s3ClientCache.GetClient(this.RegionAsEndpoint).UploadObjectFromFilePath(
                 this.linker.s3.bucket, this.linker.s3.key, sourcePath, null);
         },
         asyncOptions,
         callback);
 }
开发者ID:johnryork,项目名称:aws-sdk-unity,代码行数:18,代码来源:S3Link.Async.cs

示例10: SynchronizeOnConnectivity

 /// <summary>
 /// Attempt to synchronize <see cref="Dataset"/> when connectivity is available. If
 /// the connectivity is available right away, it behaves the same as
 /// <see cref="Dataset.SynchronizeAsync(AsyncOptions)"/>. Otherwise it listens to connectivity
 /// changes, and will do a sync once the connectivity is back. Note that if
 /// this method is called multiple times, only the last synchronize request
 /// is kept. If either the dataset or the callback is garbage collected
 /// , this method will not perform a sync and the callback won't fire.
 /// </summary>
 public virtual void SynchronizeOnConnectivity(AsyncOptions options = null)
 {
     if (_netReachability.NetworkStatus != NetworkStatus.NotReachable)
     {
         SynchronizeAsync(options);
     }
     else
     {
         waitingForConnectivity = true;
         OnConnectivityOptions = options;
     }
 }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:21,代码来源:Dataset.unity.cs

示例11: RefreshDatasetMetadataAsync

 /// <summary>
 /// Refreshes dataset metadata. Dataset metadata is pulled from remote
 /// storage and stored in local storage. Their record data isn't pulled down
 /// until you sync each dataset.
 /// </summary>
 /// <param name="callback">Callback once the refresh is complete</param>
 /// <param name="options">Options for asynchronous execution</param>
 /// <exception cref="Amazon.CognitoSync.SyncManager.DataStorageException">Thrown when fail to fresh dataset metadata</exception>
 public void RefreshDatasetMetadataAsync(AmazonCognitoSyncCallback<List<DatasetMetadata>> callback, AsyncOptions options = null)
 {
     options = options ?? new AsyncOptions();
     AmazonCognitoSyncResult<List<DatasetMetadata>> cognitoResult = new AmazonCognitoSyncResult<List<DatasetMetadata>>(options.State);
     
     InternalSDKUtils.AsyncExecutor(() =>
     {
         try
         {
             var response = Remote.ListDatasetMetadata();
             Local.UpdateDatasetMetadata(IdentityId, response);
             cognitoResult.Response = response;
         }
         catch (Exception e)
         {
             cognitoResult.Exception = e;
         }
         callback(cognitoResult);
     }, options);
 }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:28,代码来源:CognitoSyncManager.unity.cs

示例12: PopulateGetDatasetMetadataAsync

        private void PopulateGetDatasetMetadataAsync(string nextToken, List<DatasetMetadata> datasets, AmazonCognitoSyncCallback<List<DatasetMetadata>> callback, AsyncOptions options)
        {

            ListDatasetsRequest request = new ListDatasetsRequest();
            // a large enough number to reduce # of requests
            request.MaxResults = 64;
            request.NextToken = nextToken;

            client.ListDatasetsAsync(request, (responseObj) =>
            {
                Exception ex = responseObj.Exception;
                ListDatasetsResponse response = responseObj.Response;
                object obj = responseObj.state;
                if (ex != null)
                {
                    InternalSDKUtils.AsyncExecutor(() => callback(new AmazonCognitoSyncResult<List<DatasetMetadata>>(null, ex, obj)), options);
                }
                else
                {
                    foreach (Amazon.CognitoSync.Model.Dataset dataset in response.Datasets)
                    {
                        datasets.Add(ModelToDatasetMetadata(dataset));
                    }

                    nextToken = response.NextToken;

                    if (nextToken == null)
                    {
                        InternalSDKUtils.AsyncExecutor(() => callback(new AmazonCognitoSyncResult<List<DatasetMetadata>>(datasets, null, obj)), options);
                        return;
                    }
                    PopulateGetDatasetMetadataAsync(nextToken, datasets, callback, options);
                }
            },
            options);
        }
开发者ID:NathanSDunn,项目名称:aws-sdk-unity-samples,代码行数:36,代码来源:CognitoSyncStorage.cs

示例13: GetCredentialsAsync

        /// <summary>
        /// Returns an instance of ImmutableCredentials for this instance
        /// </summary>
        /// <param name="callback">The callback which is executed when the asynchronous operations is completed</param>
        /// <param name="options">Options for executing asynchronous operation</param>
        public void GetCredentialsAsync(AmazonCognitoIdentityCallback<ImmutableCredentials> callback, AsyncOptions options = null)
        {
            options = options == null ? new AsyncOptions() : options;

            CognitoIdentityAsyncExecutor.ExecuteAsync<ImmutableCredentials>(() =>
            {
                return GetCredentials();
            }, options, callback);
        }
开发者ID:NathanSDunn,项目名称:aws-sdk-unity,代码行数:14,代码来源:CognitoAWSCredentials.unity.cs

示例14: GetIdentityIdAsync

        /// <summary>
        /// Gets the Identity Id corresponding to the credentials retrieved from Cognito.
        /// Note: this setting may change during execution. To be notified of its
        /// new value, attach a listener to IdentityChangedEvent
        /// </summary>
        /// <param name="callback">The callback which is executed when the asynchronous operations is completed</param>
        /// <param name="options">Options for executing asynchronous operation</param>
        public void GetIdentityIdAsync(AmazonCognitoIdentityCallback<string> callback, AsyncOptions options = null)
        {
            options = options == null ? new AsyncOptions() : options;

            CognitoIdentityAsyncExecutor.ExecuteAsync<string>(() =>
            {
                return GetIdentityId();
            }, options, callback);
        }
开发者ID:NathanSDunn,项目名称:aws-sdk-unity,代码行数:16,代码来源:CognitoAWSCredentials.unity.cs

示例15: GetSessionTokenAsync

 /// <summary>
 /// Returns a set of temporary credentials for an AWS account or IAM user. The credentials
 /// consist of an access key ID, a secret access key, and a security token. Typically,
 /// you use <code>GetSessionToken</code> if you want to use MFA to protect programmatic
 /// calls to specific AWS APIs like Amazon EC2 <code>StopInstances</code>. MFA-enabled
 /// IAM users would need to call <code>GetSessionToken</code> and submit an MFA code that
 /// is associated with their MFA device. Using the temporary security credentials that
 /// are returned from the call, IAM users can then make programmatic calls to APIs that
 /// require MFA authentication. 
 /// 
 ///  
 /// <para>
 /// The <code>GetSessionToken</code> action must be called by using the long-term AWS
 /// security credentials of the AWS account or an IAM user. Credentials that are created
 /// by IAM users are valid for the duration that you specify, between 900 seconds (15
 /// minutes) and 129600 seconds (36 hours); credentials that are created by using account
 /// credentials have a maximum duration of 3600 seconds (1 hour). 
 /// </para>
 ///  <note> 
 /// <para>
 /// We recommend that you do not call <code>GetSessionToken</code> with root account credentials.
 /// Instead, follow our <a href="http://docs.aws.amazon.com/IAM/latest/UserGuide/IAMBestPractices.html#create-iam-users">best
 /// practices</a> by creating one or more IAM users, giving them the necessary permissions,
 /// and using IAM users for everyday interaction with AWS. 
 /// </para>
 ///  </note> 
 /// <para>
 /// The permissions associated with the temporary security credentials returned by <code>GetSessionToken</code>
 /// are based on the permissions associated with account or IAM user whose credentials
 /// are used to call the action. If <code>GetSessionToken</code> is called using root
 /// account credentials, the temporary credentials have root account permissions. Similarly,
 /// if <code>GetSessionToken</code> is called using the credentials of an IAM user, the
 /// temporary credentials have the same permissions as the IAM user. 
 /// </para>
 ///  
 /// <para>
 /// For more information about using <code>GetSessionToken</code> to create temporary
 /// credentials, go to <a href="http://docs.aws.amazon.com/STS/latest/UsingSTS/CreatingSessionTokens.html"
 /// target="_blank">Creating Temporary Credentials to Enable Access for IAM Users</a>.
 /// 
 /// </para>
 /// </summary>
  /// <param name="options">
  ///     A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
  ///     procedure using the AsyncState property.
  /// </param>
 /// 
 /// <returns>The response from the GetSessionToken service method, as returned by SecurityTokenService.</returns>
 public void GetSessionTokenAsync(AmazonServiceCallback<GetSessionTokenRequest, GetSessionTokenResponse> callback, AsyncOptions options = null)
 {
     GetSessionTokenAsync(new GetSessionTokenRequest(), callback, options);
 }
开发者ID:NathanSDunn,项目名称:aws-sdk-unity-samples,代码行数:52,代码来源:AmazonSecurityTokenServiceClient.cs


注:本文中的Amazon.Runtime.AsyncOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。