CloudBlobClient.BeginListContainersSegmented Method (String, ContainerListingDetails, Int32, ResultContinuation, AsyncCallback, Object) |
See Also Example |
Begins an asynchronous request to return a result segment containing a collection of containers with names that begin with the specified prefix, and with the specified set of details to include when listing the containers in this storage account. Use this overload when you want to control the maximum number of results returned at a time, and when you want to use a continuation token to determine whether there are more results to return from the service after the current page completes. Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in Microsoft.WindowsAzure.StorageClient.dll)
Usage
Visual Basic |
---|
Dim instance As CloudBlobClient Dim prefix As String Dim detailsIncluded As ContainerListingDetails Dim maxResults As Integer Dim continuationToken As ResultContinuation Dim callback As AsyncCallback Dim state As Object Dim returnValue As IAsyncResult returnValue = instance.BeginListContainersSegmented(prefix, detailsIncluded, maxResults, continuationToken, callback, state) |
Syntax
Visual Basic |
---|
Public Function BeginListContainersSegmented ( _ prefix As String, _ detailsIncluded As ContainerListingDetails, _ maxResults As Integer, _ continuationToken As ResultContinuation, _ callback As AsyncCallback, _ state As Object _ ) As IAsyncResult |
C# |
---|
public IAsyncResult BeginListContainersSegmented ( string prefix, ContainerListingDetails detailsIncluded, int maxResults, ResultContinuation continuationToken, AsyncCallback callback, Object state ) |
C++ |
---|
public: IAsyncResult^ BeginListContainersSegmented ( String^ prefix, ContainerListingDetails detailsIncluded, int maxResults, ResultContinuation^ continuationToken, AsyncCallback^ callback, Object^ state ) |
J# |
---|
JScript |
---|
Parameters
- prefix
Type: System.String
The container name prefix.
- detailsIncluded
Type: Microsoft.WindowsAzure.StorageClient.ContainerListingDetails
A value that indicates whether to return container metadata with the listing.
- maxResults
Type: System.Int32
A non-negative integer value that indicates the maximum number of results to be returned in the result segment, up to the per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned.
- continuationToken
Type: Microsoft.WindowsAzure.StorageClient.ResultContinuation
A continuation token returned by a previous listing operation.
- callback
Type: System.AsyncCallback
The callback delegate that will receive notification when the asynchronous operation completes.
- state
Type: System.Object
A user-defined object that will be passed to the callback delegate.
Return Value
Type: System.IAsyncResultAn IAsyncResult that references the asynchronous operation.Example
The following code sample lists containers in the storage account asynchronously, in result segments of ten containers at a time.
C# | Copy Code |
---|---|
static void ListContainersInSegmentsAsynchronously(Uri blobEndpoint, string accountName, string accountKey) { //Create service client for credentialed access to the Blob service. CloudBlobClient blobClient = new CloudBlobClient(blobEndpoint, new StorageCredentialsAccountAndKey(accountName, accountKey)); //Begin the operation to return the first segment of 10 containers in the account. blobClient.BeginListContainersSegmented( "", ContainerListingDetails.None, 10, null, ListContainersInSegmentsCallback, blobClient); } static void ListContainersInSegmentsCallback(IAsyncResult result) { CloudBlobClient blobClient = (CloudBlobClient)result.AsyncState; ResultSegment<CloudBlobContainer> resultSegment = blobClient.EndListContainersSegmented(result); //Enumerate the containers. foreach (var container in resultSegment.Results) { Console.WriteLine(container.Name); } //Check whether the page is complete. if (resultSegment.HasMoreResults) { resultSegment = resultSegment.GetNext(); //Enumerate the containers. foreach (var container in resultSegment.Results) { Console.WriteLine(container.Name); } } } |
Remarks
The BeginListContainersSegmented method begins an operation to list containers in pages. A page is set of results of a specified size; it is represented by the ResultSegment class. By returning containers in pages, you can control the number of containers returned per operation. This may be useful if, for example, you are displaying a web page with some predefined number of containers on it.
To specify the page size to return, pass in a non-zero value for the maxResults parameter. Passing in zero for the maxResults parameter returns either the maximum number of results available, or the per-operation limit of 5000 results.
If you have specified a page size, you can check the HasMoreResults property to check whether the page is complete. If HasMoreResults is true, the complete page has not been returned for some reason. Call GetNext to return the remaining results in the page.
Note that if you have not specified a page size, HasMoreResults will always be false.
Check the value of the ContinuationToken property to determine whether there are more results to return from the service after the page is complete. The continuation token is non-null as long as there are more results to return from the service. If the page is complete, then HasMoreResults will be false, but if the continuation token is non-null, there are additional results to return beyond that page.
Call the GetNext method to return the next segment of results from the service.