有人可以帮我理解这段代码是如何执行的,“结果”在哪里,我什么时候可以开始用完整的结果做事。
protected void QuerySongsExecuteSegmentedAsync(CloudTableClient cloudTableClient)
{
TableServiceContext tableServiceContext = cloudTableClient.GetDataServiceContext();
tableServiceContext.ResolveType = (unused) => typeof(Song);
CloudTableQuery<Song> cloudTableQuery =
(from entity in tableServiceContext.CreateQuery<Song>("Songs").Take(10)
select entity ).AsTableServiceQuery<Song>();
IAsyncResult iAsyncResult =
cloudTableQuery.BeginExecuteSegmented(BeginExecuteSegmentedIsDone, cloudTableQuery);
}
static void BeginExecuteSegmentedIsDone(IAsyncResult result)
{
CloudTableQuery<Song> cloudTableQuery = result.AsyncState as CloudTableQuery<Song>;
ResultSegment<Song> resultSegment = cloudTableQuery.EndExecuteSegmented(result);
List<Song> listSongs = resultSegment.Results.ToList<Song>();
if (resultSegment.HasMoreResults)
{
IAsyncResult iAsyncResult =
cloudTableQuery.BeginExecuteSegmented(
resultSegment.ContinuationToken, BeginExecuteSegmentedIsDone, cloudTableQuery);
}
}