none
System.Data.Common.DbAsyncResult problems RRS feed

  • Question

  • I'm trying to run async queries again an SQL Server 2000 database. Most of the time they work fine, but sometimes I'm seeing strange behaviour such as my callback not being called. I wrote a little unit test:

    [Test]
            public void TestGetComments()
            {
                var connection = new SqlConnection(GDNet.V4.Properties.Settings.Default.V4ConnectionString);
                connection.Open();
    
                var command = new SqlCommand{CommandText = "V5_GetComments", CommandType = CommandType.StoredProcedure};
                command.Parameters.AddWithValue("@topicid", 123456);
                command.Parameters.AddWithValue("@startIndex", 1);
                command.Parameters.AddWithValue("@endIndex", 100000);
                command.Connection = connection;
    
                bool hitCallback = false;
    
                var ar = command.BeginExecuteReader(delegate(IAsyncResult r) 
                { command.EndExecuteReader(r);
                    hitCallback = true;
                }, null);
    
                while(!ar.IsCompleted) System.Threading.Thread.Sleep(100);
    
                Assert.IsTrue(hitCallback);
            }
    When I run it, it hangs. If I break into the debugger, it's stuck on the 'while(!ar.IsCompleted)' line - ar.IsCompleted is false, but hitCallback is true. Surely that's impossible - if hitCallback is true, that can only be because it called the callback, and the only time it calls the callback is when it sets IsCompleted to true?

    Other queries that I've issued in similar ways seem to work fine; it's just this one that behaves oddly. The differences I can think of are that it's a stored procedure (while the others are just plain text queries) and it returns multiple result sets (while the others just return one result set). I can't see those making a difference though.

    Richard Fine (DirectX MVP)
    Wednesday, March 10, 2010 7:18 AM

All replies

  • Hi,

    It seems that your question is ADO.net specific, please try this forum instead: http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/threads  :)

    Regards,
    PQ
    Peter Q. http://blogs.msdn.com/peter_qian
    Wednesday, March 10, 2010 7:26 AM
    Answerer
  • Hello Richard,

     

    Welcome to ADO.NET Data Providers forum!

     

    It is really strange problem.   Have you tried other stored procedure returns single result set?   Or make this stored procedure into plain SQL command?   

     

    Also, is it convenient for you to test similar logic on SQL Server 2005 or 2008?   Similar logic works fine at my side. 

     

    Have a nice weekend!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, March 12, 2010 6:28 AM
    Moderator
  • Hi Richard,

     

    I am writing to check the status of the issue on your side.  Would you mind letting us know the result of the suggestions? 

     

    If you need further assistance, please feel free to let me know.   I will be more than happy to be of assistance.

     

    Have a nice day!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, March 16, 2010 1:21 AM
    Moderator