I am working with scheduler control.
Scenario- I have added a ResourcesCheckedListBoxControl for filtering the resources . For faster loading i have used Multi threading concept
When i do it normal way it loads the ResourcesCheckedListBoxControl but when i go with threading it does not work. . See the following code
Visual BasicPrivate Sub frmScheduler_Load(sender As Object, e As EventArgs) Handles MyBase.Load
bw = New BackgroundWorker()
AddHandler bw.DoWork, AddressOf bw_DoWork
'AddHandler bw.ProgressChanged, AddressOf bw_ProgressChanged
AddHandler bw.RunWorkerCompleted, AddressOf bw_RunWorkerCompleted
bw.WorkerReportsProgress = True
bw.WorkerSupportsCancellation = True
If bw.IsBusy = False Then
MarqueeProgressBarControl1.Visible = True
bw.RunWorkerAsync()
End If
End sub
Private Sub bw_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
Dim worker As BackgroundWorker = CType(sender, BackgroundWorker)
If bw.CancellationPending = True Then
e.Cancel = True
Exit Sub
Else
Try
Parallel.Invoke(Sub()
'SchedulerControl1.DayView.TimeIndicatorDisplayOptions.ShowOverAppointment = True
Me.SpSALScheduler_siudTableAdapter1.Fill(Me.ResourceDataSet.spSALScheduler_siud)
End Sub,
Sub()
Me.SpSALScheduler_siudTableAdapter.Fill(Me.SALDataSet.spSALScheduler_siud)
End Sub)
Catch ex As Exception
End Try
End If
End Sub
Private Sub bw_RunWorkerCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs)
MarqueeProgressBarControl1.Visible = False
If Me.InvokeRequired Then
Me.Invoke(New MethodInvoker(AddressOf UpdateUI))
End If
End Sub
In the above code I have used backgrounder to show progress bar and Parallel.Invoke for parallel filling dataset. The code work fine . but resources does not load into the ResourcesCheckedListBoxControl . The resources should show on the ResourcesCheckedListBoxControl .
I have tried another concept of threading please see the below code
Visual BasicDim task1 As Task = Task.Factory.StartNew(Function() Me.SpSALScheduler_siudTableAdapter.Fill(Me.SALDataSet.spSALScheduler_siud))
Dim task2 As Task = Task.Factory.StartNew(Function() Me.SpSALScheduler_siudTableAdapter1.Fill(Me.ResourceDataSet.spSALScheduler_siud))
'Dim task3 As Task = Task.Factory.StartNew(Function() doStuff("Task3"))
Task.WaitAll(task1, task2)
this one also fails to load ResourcesCheckedListBoxControl