Asynchronous data access in ASP.NET

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vpidatala@yahoo.com

    #1

    Asynchronous data access in ASP.NET

    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.Sql Client.SqlDataR eader
    Dim dr As System.Data.Sql Client.SqlDataR eader


    '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.Sql Client.SqlDataR eader
    Private Function getdataAsync() As
    System.Data.Sql Client.SqlDataR eader
    Dim dlgt As New AsyncDelegate(A ddressOf getdata)
    Dim ar As IAsyncResult = dlgt.BeginInvok e(Nothing, Nothing)
    'display(AppDom ain.GetCurrentT hreadId()) (this a thread)
    Thread.Sleep(0)
    Dim adr As System.Data.Sql Client.SqlDataR eader =
    dlgt.EndInvoke( ar)
    'display(AppDom ain.GetCurrentT hreadId()) (this is a different
    thread than the above.)
    Return adr
    End Function


    I greatly appreciate any help.

Working...