QueryAsync

using System;
using System.Collections.Generic;
using System.Data.Services.Client;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bing
{
    public static class QueryExtensions
    {
        public static Task<IEnumerable<TResult>> QueryAsync<TResult>(this DataServiceQuery<TResult> query)
        {
            return Task<IEnumerable<TResult>>.Factory.FromAsync(query.BeginExecute, query.EndExecute, null);
        }
    }
}
Example:
BingSearchContainer _bsc = new BingSearchContainer(new Uri("https://api.datamarket.azure.com/Bing/Search/"));

var webQ = _bsc.Image("search", null, null, null, null, null);

var result = await webQ.QueryAsync() ;

Description

Returns a Task<IEnumerable<TResult>> to be used with the new async / await keyword.

Details

Double click on the code to select all.

 

;