I have a long running stored procedure, spLongRunningProcesswhen I call it using the Async Await it runs and executes just fine, However I need to call it without waiting for the response because it is a very long running process.. Here is my code below I am missing something but can't quite nail it down.
public async Task<ResultObject> LongSPCallAsync()
{
ResultObject ro = new ResultObject();
try
{
using (_context = new DbContext())
{
SqlParameter returnVal2 = new SqlParameter("@ReturnVal2", SqlDbType.Int)
{
Direction = ParameterDirection.Output
};
_context.Database.ExecuteSqlCommandAsync("EXEC @ReturnVal2 = [spLongRunningProcess]", returnVal2).ConfigureAwait(false); //<-- This NEVER runs unless I await it.?
var oooo = returnVal2.Value; //<-- just orphan code for debugging.
}
}
catch (Exception e)
{
await _logService.AddLogAsync(e, $"Error running SP:", "spLongRunningProcess");
}
return ro;
}
In the Conn string I have specified (Asynchronous Processing=True)
To Verify if it actually is running I'm just checking the database through another process. Just looking for what I missed.