Hallo zusammen,
close auf Datareader benötigt sehr lange.
in dem folgendem Beispiel werden 10000 Records
in MSSQL Datenbank asyncron in einem BackgroudWorker
gelesen.
Das vorzeitige Beenden wird über einen cancel Button initiert.
Die Subroutine SelectAsyn() bleibt jedoch sehr lange
beim close des Datenreaders hängen ?
Warum ?
Mfg
Jürgen Bartels
#Region "BackGroundWorker mit Asyncroner DatenbankSelection"
Private Sub BackgroundWorker2_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker2.DoWork
SelectAsync()
End Sub
Private Sub SelectAsync()
cancel = False
Dim aCon As New SqlConnection
aCon.ConnectionString = "Data Source=192.168.1.20;Initial Catalog=TESTDB;Persist Security Info=True;User ID=Bill;Password=Gates; Asynchronous Processing=true"
aCon.Open()
Dim aCmd As New SqlCommand("Select Top 10000 * from Adressen", aCon)
Dim myresult As IAsyncResult = aCmd.BeginExecuteReader
Dim i As Integer = 0
Do While (Not myresult.IsCompleted)
i += 1
If Me.cancel = True Then
aCmd.Cancel()
cancel = False
Exit Do
End If
Loop
Dim myReader As SqlDataReader = aCmd.EndExecuteReader(myresult)
i = 0
Do While myReader.Read()
i += 1
If Me.cancel = True Then Exit Do
Loop
'------------------------------------------------------
' Der reader.close benötigt für 10000 Records 10 Sec
' wenn die Selection vorzeitig abgebrochen wurde
' warum ?
'
'------------------------------------------------------
myReader.Close()
aCon.Close()
Me.cancel = True
End Sub
#End Region
close auf Datareader benötigt sehr lange.
in dem folgendem Beispiel werden 10000 Records
in MSSQL Datenbank asyncron in einem BackgroudWorker
gelesen.
Das vorzeitige Beenden wird über einen cancel Button initiert.
Die Subroutine SelectAsyn() bleibt jedoch sehr lange
beim close des Datenreaders hängen ?
Warum ?
Mfg
Jürgen Bartels
#Region "BackGroundWorker mit Asyncroner DatenbankSelection"
Private Sub BackgroundWorker2_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker2.DoWork
SelectAsync()
End Sub
Private Sub SelectAsync()
cancel = False
Dim aCon As New SqlConnection
aCon.ConnectionString = "Data Source=192.168.1.20;Initial Catalog=TESTDB;Persist Security Info=True;User ID=Bill;Password=Gates; Asynchronous Processing=true"
aCon.Open()
Dim aCmd As New SqlCommand("Select Top 10000 * from Adressen", aCon)
Dim myresult As IAsyncResult = aCmd.BeginExecuteReader
Dim i As Integer = 0
Do While (Not myresult.IsCompleted)
i += 1
If Me.cancel = True Then
aCmd.Cancel()
cancel = False
Exit Do
End If
Loop
Dim myReader As SqlDataReader = aCmd.EndExecuteReader(myresult)
i = 0
Do While myReader.Read()
i += 1
If Me.cancel = True Then Exit Do
Loop
'------------------------------------------------------
' Der reader.close benötigt für 10000 Records 10 Sec
' wenn die Selection vorzeitig abgebrochen wurde
' warum ?
'
'------------------------------------------------------
myReader.Close()
aCon.Close()
Me.cancel = True
End Sub
#End Region
Comment