Hi Linda,
Thanks for your reply. I am sending you a copy of the offending code. I
appreciate your time on this...
Private Sub DeniedClaimsForm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'' Start the asynchronous operation.
BackgroundWorker1.RunWorkerAsync()
Me.Cursor = Cursors.WaitCursor
Me.SuspendLayout()
Me.cmdPrint.Visible = True
ConfigureClaimDataGrid()
ConfigureSvcLineDataGrid()
DisableDGAddNew(Me.dgDeniedClaims, Me)
DisableDGDelete(Me.dgDeniedClaims, Me)
Me.cmdClose.Focus()
Me.ResumeLayout()
Me.Cursor = Cursors.Default
End Sub
' This event handler is where the actual work is done.
Private Sub backgroundWorker1_DoWork( _
ByVal sender As Object, _
ByVal e As DoWorkEventArgs) _
Handles BackgroundWorker1.DoWork
' Get the BackgroundWorker object that raised this event.
Dim worker As BackgroundWorker = _
CType(sender, BackgroundWorker)
' Assign the result of the data loading
' to the Result property of the DoWorkEventArgs
' object. This is will be available to the
' RunWorkerCompleted eventhandler.
e.Result = Me.LoadDataSet(worker, e)
End Sub 'backgroundWorker1_DoWork
' This event handler deals with the results of the
' background operation.
Private Sub backgroundWorker1_RunWorkerCompleted( _
ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs) _
Handles BackgroundWorker1.RunWorkerCompleted
Try
Me.Cursor = Cursors.Default
' First, handle the case where an exception was thrown.
If Not (e.Error Is Nothing) Then
LogExceptions(Me.Name, "RunWorkerCompleted", e.Error)
MessageBox.Show(strDBerror, strSrvrError,
MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Close()
ElseIf CBool(e.Result) = False Then
MessageBox.Show("There are no unresolved denied claims")
Me.Close()
Else
Me.lbDeniedBal.Text = Me.ReturnTotalDeniedBalance
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
Finally
Me.BackgroundWorker1.Dispose()
End Try
End Sub 'backgroundWorker1_RunWorkerCompleted
Private Function LoadDataSet(ByVal worker As BackgroundWorker, ByVal e
As DoWorkEventArgs) As Boolean
'Private Function LoadDataSet() As Boolean
Dim cn As New SqlConnection(strConn)
Try
Me.daDeniedClms.SelectCommand.Connection = cn
Me.daDeniedSvcLines.SelectCommand.Connection = cn
With Me.DsDeniedClaims1
.Clear()
'worker.ReportProgress(25)
cn.Open()
' Report progress as a percentage of the total task.
If Me.daDeniedClms.Fill(.dtDeniedClaims) > 0 Then
'worker.ReportProgress(50)
Me.daDeniedSvcLines.Fill(.dtDeniedServiceLines)
'worker.ReportProgress(95)
Else
cn.Close()
Return False
End If
If cn.State = ConnectionState.Open Then cn.Close()
.EnforceConstraints = True
End With
Return True
Catch ex As Exception
LogExceptions(Me.Name, "LoadDataSet", ex)
Return False
Finally
cn.Dispose()
End Try
End Function

Signature
John
> Hi John,
>
[quoted text clipped - 40 lines]
> from your issue.
> ====================================================
Linda Liu [MSFT] - 12 May 2006 06:06 GMT
Hi John,
Thank you for your quickly response.
I performed a test based on your code. Unfortunately, I couldn't reproduce
the problem you mentioned. The program didn't hang either with or without
debugging when I hit the close button on the form.
If possible, would you please set up a simple project which could just
reproduce the problem and send it to me? To get my actual email, please
remove the "online" from my displayed email address. Thanks.
Sincerely,
Linda Liu
Microsoft Online Community Support
====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
JT - 16 May 2006 02:39 GMT
Hi Linda,
I fixed my problem. I basically moved the following code from Form_Load to
RunWorkerCompleted...
Me.SuspendLayout()
Me.cmdPrint.Visible = True
ConfigureClaimDataGrid()
ConfigureSvcLineDataGrid()
DisableDGAddNew(Me.dgDeniedClaims, Me)
DisableDGDelete(Me.dgDeniedClaims, Me)
Me.cmdClose.Focus()
Me.ResumeLayout()
Me.Cursor = Cursors.Default
Works fine now. Thanks.
John
> Hi John,
>
[quoted text clipped - 17 lines]
> from your issue.
> ====================================================
Linda Liu [MSFT] - 16 May 2006 06:25 GMT
Hi John,
Thank you for your response. I am glad to hear that the problem has been
fixed.
I think the problem may be cause by calling the ConfigureClaimDataGrid()
and ConfigureSvcLineDataGrid() methods in the form's load event handler.
Since the BackgroundWorker is dealing with the DataTable in your project,
there may be a conflict between the BackgroundWorker and
ConfigureClaimDataGrid() or ConfigureSvcLineDataGrid() methods.
If you have any other concerns or need anything else, please do not
hesitate to contact us. It is always our pleasure to be of assistance.
Have a nice day!
Sincerely,
Linda Liu
Microsoft Online Community Support
====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================