ListVersionsAsync() public method

Initiates the asynchronous execution of the ListVersions operation.
public ListVersionsAsync ( ListVersionsRequest request, System cancellationToken = default(CancellationToken) ) : Task
request ListVersionsRequest Container for the necessary parameters to execute the ListVersions operation.
cancellationToken System /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. ///
return Task
示例#1
0
        public static List<S3ObjectVersion> ListVersionsHelper(AmazonS3Client client, string bucketName)
        {
            AutoResetEvent ars = new AutoResetEvent(false);
            Exception responseException = new Exception();
            List<S3ObjectVersion> s3ObjectVersions = null;
            client.ListVersionsAsync(new ListVersionsRequest()
            {
                BucketName = bucketName
            }, (response) =>
            {
                responseException = response.Exception;
                if (responseException == null)
                {
                    s3ObjectVersions = response.Response.Versions;
                }
                ars.Set();
            }, new AsyncOptions { ExecuteCallbackOnMainThread = false });

            ars.WaitOne();
            if (responseException != null)
            {
                throw responseException;
            }
            return s3ObjectVersions;
        }