DataGridView Update

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

I am using VS 2005 and would like to accomplish the following:

Assuming I have 3-4 grids on a given Windows Form. I would like to
update these grids individually on a specified timer interval without
blocking the UI thread. When the info is available for a specific grid, it
is updated with the latest values from the SQL Server 2000 database backend.

What would be the best way to do this? I think I'd need to start a new
thread for each grid's Update/Refresh method or maybe even use the new
BackgroundThreadWorker object. Any ideas, hints, code tips (VB.NET).


Regards,

Giovanni P.
 
Giovanni,

And this does mean that you wont try to update the data from your datagrids
to your database?.

Cor
 
Hi Cor,

No, the grids are for display purposes only to return real-time
inventory information from the warehouse.


Regards,

Giovanni
 
Giovanni,

I have not tried it yet, however I would first go in your case for the
backgroundworker class.

In my opinion is this made for that.

Cor
 
Giovanni,
What you would do is use a System.Timers.Timer to run in a second thread,
someone suggested the Backgroundworker class, but this will only work if you
are using .net 2.0. You'll have to set up the AsyncResult yourself if you
are using .net 1.1

This is a pretty good summary of basically what you are trying to do from
Mike Taulty, this will also point you in the right direction if you have to
set up the AsyncResult yourself versus using the BackgroundWorker class...

http://www.microsoft.com/uk/asx/msdn/nuggets/asynchronouswebservicecalls.asx

Since the background thread is trying to update the UI (in another thread,
which isn't allowed), you'll need to Invoke a delegate to refresh the
datagrid. A good example of using Invoke to do this can be found in the
excelent C# FAQ here:

http://blogs.msdn.com/csharpfaq/archive/2004/03/17/91685.aspx

Goodluck,
Michael.
 
Back
Top