Asynchronous data access in ASP.NET

V

vpidatala

Hi All,

I am lil confused with different ways of asynchronous data access.

My understanding is that, asynchronous data access frees up a thread
instead of engaging it while a stored proc is being executed. This
makes more threads available. Is this correct or are there ay other
advantages of asynchronous data access?

My questions are:

1. I cannot set the async page directive to true as suggested in
some articles. I get an error saying incorrect page directive.

2. I can set async attribute in connection string as suggested in
few articles. I get error 'Keyword not supported.


Am I missing something to get the above errors or the articles I got
the above information from are outdated?

Here is my code. I made sense from 100 different sources before coding.
Would some one tell me if I am doing it correctly? I correctly see
deferent thread id's before and after data access.

Private Function getdata() As System.Data.SqlClient.SqlDataReader
Dim dr As System.Data.SqlClient.SqlDataReader

'code to run any sql get dr
If dr Is Nothing OrElse dr.IsClosed OrElse Not dr.HasRows Then
Return Nothing
Exit Function
End If
Return dr
End Function
Public Delegate Function AsyncDelegate() As
System.Data.SqlClient.SqlDataReader
Private Function getdataAsync() As
System.Data.SqlClient.SqlDataReader
Dim dlgt As New AsyncDelegate(AddressOf getdata)
Dim ar As IAsyncResult = dlgt.BeginInvoke(Nothing, Nothing)
'display(AppDomain.GetCurrentThreadId()) (this a thread)
Thread.Sleep(0)
Dim adr As System.Data.SqlClient.SqlDataReader =
dlgt.EndInvoke(ar)
'display(AppDomain.GetCurrentThreadId()) (this is a different
thread than the above.)
Return adr
End Function

I greatly appreciate any help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top