Asynchron
-
In a Page (there is no async=true tag); i call a procedure asynchrously. Sometimes it calls the callback; sometimes not. Why do i face this reason?
private void AsynchronProcedure()
....
try
{
dbSqlConnection.Open();IAsyncResult asyncResult = dbSqlCommand.BeginExecuteNonQuery(MyCallBack, dbSqlCommand); } catch (Exception ex) { } finally { dbSqlConnection.Close(); } } private void MyCallBack(IAsyncResult asyncResult) { SqlCommand dbSqlcommand = (SqlCommand)asyncResult.AsyncState; try { if (asyncResult.IsCompleted) { dbSqlcommand.EndExecuteNonQuery(asyncResult); } } catch (Exception ex) { } }
-
In a Page (there is no async=true tag); i call a procedure asynchrously. Sometimes it calls the callback; sometimes not. Why do i face this reason?
private void AsynchronProcedure()
....
try
{
dbSqlConnection.Open();IAsyncResult asyncResult = dbSqlCommand.BeginExecuteNonQuery(MyCallBack, dbSqlCommand); } catch (Exception ex) { } finally { dbSqlConnection.Close(); } } private void MyCallBack(IAsyncResult asyncResult) { SqlCommand dbSqlcommand = (SqlCommand)asyncResult.AsyncState; try { if (asyncResult.IsCompleted) { dbSqlcommand.EndExecuteNonQuery(asyncResult); } } catch (Exception ex) { } }
greekius wrote:
In a Page (there is no async=true tag); i call a procedure asynchrously.
Two different things. The former for for page handling. The latter is you. Neither has an effect on each other.
greekius wrote:
Sometimes it calls the callback; sometimes not. Why do i face this reason?
Your code is wrong. You should close the connection after the callback returns, not before it (as you are doing now, not really, it depends, but the fact is the connection can and likely will be closed before the async call can complete).
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008)