Hello,
I am writing a program that assigns data sources to crystal report documents and assigns them to crystal report viewer on a Windows form. To make the UI responsive I chose to implement this inside new threads. My Sub does some database binding and then assigns the datasource to the crystal viewer which is naturally running in the UI main thread.
As usual, I had to use delegates and invoke. What I am doing is that I am checking whether the viewer is invoked before modifying its data source.
Please find below my code:
Now my problem is that I noticed that every time an invoke is performed the SUB is called again and so doing the same job twice.
This applies on modification that I might want to do on CrystalViewer. Is there a way to avoid this? 
Thanks
I am writing a program that assigns data sources to crystal report documents and assigns them to crystal report viewer on a Windows form. To make the UI responsive I chose to implement this inside new threads. My Sub does some database binding and then assigns the datasource to the crystal viewer which is naturally running in the UI main thread.
As usual, I had to use delegates and invoke. What I am doing is that I am checking whether the viewer is invoked before modifying its data source.
Please find below my code:
VB.NET:
Private Sub ShowAllEmployees()
Dim myDoc as New CrystalDecisions.CrystalReports.Engine.ReportDocument
MyDoc= New rpt_Emps()
'Fill Data Adapter Code
EmpTableAdapter.FillBy_All_Employees(Me.DataSet.Employees)
'Set Report Datasource Property
rptDoc.SetDataSource(DataSet)
'Assign the dataset to the report. Since this SUB is running in a separate thread from the UI. It must
'be(passed) to the UI main thread through a delegate.
If CrystalViewer.InvokeRequired Then
Dim newDelegate As New UIDelegate(AddressOf ShowAllEmployees)
CrystalViewer.Invoke(newDelegate)
Else
CrystalViewer.ReportSource = rptDoc
End If
End Sub
Now my problem is that I noticed that every time an invoke is performed the SUB is called again and so doing the same job twice.
Last edited: