コード例 #1
0
        /// <summary>
        ///     Returns an enumerable collection of tables in the storage account asynchronously.
        /// </summary>
        /// <param name="tableClient">Cloud table client.</param>
        /// <param name="prefix">The table name prefix.</param>
        /// <param name="maxResults">
        ///     A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the
        ///     per-operation limit of 5000. If this value is zero the maximum possible number of results will be returned, up to 5000.
        /// </param>
        /// <param name="continuationToken">Continuation token.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <returns>
        ///     An enumerable collection of tables that are retrieved lazily.
        /// </returns>
        public static Task <TableResultSegment> ListTablesSegmentedAsync(
            this CloudTableClient tableClient,
            string prefix,
            int?maxResults,
            TableContinuationToken continuationToken,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            ICancellableAsyncResult       asyncResult  = tableClient.BeginListTablesSegmented(prefix, maxResults, continuationToken, null, null, null, null);
            CancellationTokenRegistration registration = cancellationToken.Register(p => asyncResult.Cancel(), null);

            return(Task <TableResultSegment> .Factory.FromAsync(
                       asyncResult,
                       result =>
            {
                registration.Dispose();
                return tableClient.EndListTablesSegmented(result);
            }));
        }