.NET 2.0 BackgroundWorker
-
Im not sure exactly what the problem is, but when i fill my dataset using a background worker, the data never shows in my grid...this is not an issue when not using a background worker...any sugestions? below is the only code in the background worker:
DsCustomersGrid1.Clear() DsCustomersGrid1.Merge((New DSCustomersGridTableAdapters.SelectAllCustomersForGridTableAdapter).GetData(ZipsCommon.SetupInfo.StoreID, True))
Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so
-
Im not sure exactly what the problem is, but when i fill my dataset using a background worker, the data never shows in my grid...this is not an issue when not using a background worker...any sugestions? below is the only code in the background worker:
DsCustomersGrid1.Clear() DsCustomersGrid1.Merge((New DSCustomersGridTableAdapters.SelectAllCustomersForGridTableAdapter).GetData(ZipsCommon.SetupInfo.StoreID, True))
Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so
This is because you can't update a control (even it's data) from a seperate thread. You have to Invoke a method on the UI thread to update the control for you. Create a method on your form that takes the data as a parameter and adds the data to the control. Invoke this method from your background thread and it'll marshal the call to the UI thread to do the work.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
This is because you can't update a control (even it's data) from a seperate thread. You have to Invoke a method on the UI thread to update the control for you. Create a method on your form that takes the data as a parameter and adds the data to the control. Invoke this method from your background thread and it'll marshal the call to the UI thread to do the work.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007Doesn't this defeat the purpose of a background worker? Invoke would cause the method to run back on the main thread, which would bog down the thread since they have over 50,000 customers that are being loaded into the dataset...Is there a way to do this on a separate thread? I guess I could run it on the background worker and then send each individual row to the main thread one at a time with invoke, that would keep it from bogging down, but it would take so long to load that they would end up having to wait for the grid to load before they could really do anything anyways...any suggestions?
Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so
-
Doesn't this defeat the purpose of a background worker? Invoke would cause the method to run back on the main thread, which would bog down the thread since they have over 50,000 customers that are being loaded into the dataset...Is there a way to do this on a separate thread? I guess I could run it on the background worker and then send each individual row to the main thread one at a time with invoke, that would keep it from bogging down, but it would take so long to load that they would end up having to wait for the grid to load before they could really do anything anyways...any suggestions?
Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so
You can load the dataset entirely in the background thread, then Invoke the binding through the UI thread. Personally, I find havin 50,000 records in a DataSet a waste of time if all you're going to do is show a small block of records out of that set or doing some processing on only a small block of that data. A paging solution would be in order for this...
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
You can load the dataset entirely in the background thread, then Invoke the binding through the UI thread. Personally, I find havin 50,000 records in a DataSet a waste of time if all you're going to do is show a small block of records out of that set or doing some processing on only a small block of that data. A paging solution would be in order for this...
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007I agree with that 100%, unfortunately my boss wants it to show all of the records, with a scroll bar down the right side...I'll try loading the dataset on the background worker and then passing it back through the e.result and merging on the worker complete event. Thanks for the help :)
Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so