title: How do I use Azure TableClient 2.0 BeginExecuteQuerySegmented
body: <p>I'm trying to get all entries in my table asynchronously but am unable to figure out how to work with the <a href="http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storage.table.tablecontinuationtoken.aspx" rel="nofollow">continuation token</a>.  I suspect I need to take my anonymous method and convert it to a delegate, then recursively call it with the continuation token. </p>
  
  <p>How do I take the following code and perform an Async call and fetch all entries in the new API?</p>
  
  <pre><code> Task&lt;string[]&gt; GetAllTableEntries(CloudTable tbl, string[] urls, string name, CancellationToken token)
      {
          TableRequestOptions reqOptions = new TableRequestOptions() { };
          OperationContext ctx = new OperationContext() { ClientRequestID = "" };
          object state = null;
  
          // Register Cancelation Token
          ICancellableAsyncResult result = null;
  
          TableQuery qry = new TableQuery();
          TableContinuationToken tok = null;
  
          result = tbl.BeginExecuteQuerySegmented(qry, tok, reqOptions, ctx, (o) =&gt;
          {
  
              var response = (o.AsyncState as CloudTable).EndExecuteQuerySegmented(o);
  
              Console.WriteLine("Found " + response.Results.Count + " records");
  
              // The following code was used in the previous version of the SDK
              //
              //26:                      // add first segment of data
              //27:                      pageData.CompletedList.AddRange(
              //28:                          from wu in response.Results
              //29:                          select new CompletedWorkUnit(wu));
              //30:   
              //31:                      // continue fetching segments to complete page
              //32:                      while (response.HasMoreResults)
              //33:                      {
              //34:                          response = response.GetNext();
              //35:                          pageData.CompletedList.AddRange(
              //36:                              from wu in response.Results
              //37:                              select new CompletedWorkUnit(wu));
              //38:                      }
              //39:   
              //40:                      // set continuation token for next page request
              //41:                      pageData.ContinuationToken = response.ContinuationToken;
              //42:                      evt.Set();
  
          }, state);
  
          // Add cancellation token according to guidance from Table Client 2.0 Breaking Changes blog entry
          token.Register((o) =&gt; result.Cancel(), state);
  </code></pre>