public ICancellableAsyncResult BeginListTablesSegmented(TableContinuationToken currentToken, AsyncCallback callback, object state) { return(_cloudTableClient.BeginListTablesSegmented(currentToken, r => { var t = new AdapterAsyncResult <ITableResultSegment>(r, new TableResultSegmentAdapter( r.AsyncState as TableResultSegment)); callback(t); }, state)); }
public static Task <TableResultSegment> ListTablesAsync( this CloudTableClient client, TableContinuationToken token, CancellationToken ct = default(CancellationToken)) { ICancellableAsyncResult ar = client.BeginListTablesSegmented(token, null, null); ct.Register(ar.Cancel); return(Task.Factory.FromAsync <TableResultSegment>(ar, client.EndListTablesSegmented)); }
/// <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); })); }