none
Using ExecuteStoreQueryAsync inside an Asp.Net Application in C# RRS feed

  • Question

  • I have an Asp.Net web forms application and in the `Page_Load event` of my page I have the below code

        protected async void Page_Load(object sender, EventArgs e)
          {
             var data = await ChartDataHelper.GetBidsAverageCycle("2018", "Q4",              
                        "Fiscal");
              SomeSyncOperation();
          }

    and here's the main method

        public static async Task<List<BidAveragceCycleModel>> GetBidsAverageCycle(string year, string quarter, string yearType)
                {
                    SqlParameter parameter1 = new SqlParameter("@RequestData", BuildMonthsFilter(year, quarter, yearType));
                    var data =await Entities.Current.ExecuteStoreQueryAsync<BidAveragceCycleModel>("exec Dashboard_Bids_AverageCycleTime @RequestData"
                         , new[] { parameter1 });
                    return data.ToList();
                }

    I was thinking having `await on the ExecuteStoreQueryAsync will return the control back to Page_Load and call SomeSyncOperation()` but looks like it is running in a `synchronous fashion` and after 10 seconds when the Stored Proc returns data it then calls `data.ToList()` and then only returns back to `Page_Load` call. 

    Can someone please tell me what I am doing wrong here. 

    Thanks
    • Moved by CoolDadTx Thursday, April 4, 2019 5:54 PM ASP.NET related
    Thursday, April 4, 2019 5:11 PM

All replies