I have a progress bar set to marquee on an mdi parent status bar. To make it run smoothly and continuously while updating I thought it may be time to try somehting new rather than Application.DoEvents.
So I have a procedure in a child form which is called by the following
....enable the progress bar
Dim newthread As New Threading.Thread(AddressOf MyProcedure)
The procedure fills a datatable from various tables, then a DataView which is sorted, which is then used to populate a DataGridView control. I have found out that (via debug message) I have to check the DataGridView.InvokeRequired property when i try to set the DataGridView datasource, and then do something else if the answer is True, when doing something to a control not invoked by the same thread. I am not sure what code I need if the answer is true.
Private Sub MyProcedure()
....do some stuff
If MyDataGridView.InvokeRequired Then
......WHAT GOES HERE
MyDataGridView.DataSource = MyDataView
'Disable progress bar
me.cursor = cursors.default
PS. I have also discovered i will get the same problem when i try to reset the cursor for the form back to default and also try to disable the progress bar as they were set on different threads
I am assuming of course this is the way to go for smoothly operating progress bars