I have a stored procedure that writes a backup of a specific database. I call this SP in a C # / Windows Forms application asynchrounously. Below is the code:
IAsyncResult result = command.BeginExecuteNonQuery();
while (!result.IsCompleted)
{
System.Threading.Thread.Sleep(1000);
...
}
command.EndExecuteNonQuery(result));
After a while, the program leaves the loop because IsCompleted = true and calls EndExecuteNonQuery. Now the problem is that Job is still busy and EndExecuteNonQuery is locked ! This will expire the server in a few minutes. It seems that the value of IsCompleted does not match, respectively, what is wrong with IsCompleted ? How can I ensure that my program recognizes the status of real work " ?
source
share