private async Task<string> getDeviceDescription(int manufacture, string serialNu
ID: 3908226 • Letter: P
Question
private async Task<string> getDeviceDescription(int manufacture, string serialNumber)
{
var output = new sqlParameter("@deviceDescription", sqlDbType.NVarChar, 255) { Direction = ParameterDirection. Output };
await Database.ExecuteSqlCommandAsync("exec storedProcedure @manufacture, @serialNumber, @deviceDescription OUT", new sqlParameter("@manufacture", manufacture), new sqlParameter("@serialNumber", serialNumber), output);
description = (string) output.Value;
return description;
}
I keep getting System.AggregateException: One or more errors occurred. ---> System.NotSupportedException: A second operation started on this context before a previous asynchronous operation completed. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context. Any instance members are not guaranteed to be thread safe.
Explanation / Answer
The error is happening because the first when it is called it worked but for the next time it will show the error. The main thing is that the await keyword is not there. Hence every time it will give the container a task and subsequently the task will never complete because it is not awaited.
Here for this the missing await should be added.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.