It is my understanding that the awaitable completes the remaining part of the executing code when they return back from the wait. I am trying to get this to work in an sql clr, and this is not working as both awaited process and codes beneath it are not getting executed. In debug method, the control just returns after executing the await line.
how can i make this work, as the requirement is for clr to be executed without blocking the main thread so that other work can continue well in the db. I really need this to work, and have been on it for 2 days now.
NB This works well if method is sync. And the stored proc assemble is registered as unsafe in sql server. I am using mssql 2012 and visual studio 2015.
public partial class StoredProcedures
{
[Microsoft.SqlServer.Server.SqlProcedure]
public static async void sp_push_stock_update(SqlString transactionPrimaryKey, SqlString transactionType)
{
using (SqlConnection conn = new SqlConnection("context connection=true"))
{
StockUpdateClient.stock_fetcher _stockFetcher = new StockUpdateClient.stock_fetcher(conn);
List<String> skuList = await new
System.Threading.Tasks.Task<List<string>>(()=>
_stockFetcher.getItems(transactionPrimaryKey, transactionType));
//Code does not get here
performLogging(skuList):
}
}
}