views:

17

answers:

0

Hello

is there any shorter way to consume an asynchronous WCF method in a ASP.NET page?

here is a sample I would like to refactor:

protected void Button1_Click(object sender, EventArgs e)
{
    PageAsyncTask c = new PageAsyncTask(AsyncList, CallbackList, null, null);
    Page.RegisterAsyncTask(c);   
}

IAsyncResult AsyncList(object sender, EventArgs e, AsyncCallback acb, object extraData)
{
    db = new Product.NorthwindServiceClient();
    return db.BeginProductList(acb, extraData);
}

void CallbackList(IAsyncResult ar)
{
    var prods = new List<Products>();
    ListBox1.DataSource = db.EndProductList(ar);
    ListBox1.DataTextField = "ProductName";
    ListBox1.DataValueField = "ProductID";
    ListBox1.DataBind();
}