ADO.NET and Threading

F

Frank Uray

Hi all

I have some trouble with multithreading:
- I have a Main Application (as MDI Container).
- I create a new form with multithreading on it, it just
updates periodicaly some values.
- Now I create a new form with a grid. I fill the grid
using ADO.NET. The problem is now, while the grid
is filled, the thread on the other form is blocked.

Does anybody knows how to change this to have
it really multithreaded ? I also already tried to run
it in a separate AppDomain but its the same problem.

Thanks and best regards
Frank Uray
 
F

Family Tree Mike

Frank said:
Hi all

I have some trouble with multithreading:
- I have a Main Application (as MDI Container).
- I create a new form with multithreading on it, it just
updates periodicaly some values.
- Now I create a new form with a grid. I fill the grid
using ADO.NET. The problem is now, while the grid
is filled, the thread on the other form is blocked.

Does anybody knows how to change this to have
it really multithreaded ? I also already tried to run
it in a separate AppDomain but its the same problem.

Thanks and best regards
Frank Uray

You need to so some code, but, all updates to the UI are occuring back
on the same UI thread, which is blocked by bullet number three.
 
P

Patrice

Periodically that is ?

Don't forget that updating from a background thread is not enough. If you
call the UI thread frequently you'll still end up in keeping it busy.

How much often do you update your UIs...
--
Patrice


"Frank Uray" <[email protected]> a écrit dans le message
de groupe de discussion :
(e-mail address removed)...
 
F

Frank Uray

Hi Patrice

Thanks for your answer.

Well, the UI Thread is updating the form each second.
The thread on the other form just connects to a database and gets some data
into a grid. I implemented this with a new thread and I use BeginInvoke
to update the grid.

Thanks and best regards
Frank Uray
 
F

Frank Uray

Hi Patrice

No, just with the fill method of the adapter.
But anyway, I would like to have the other form (not the grid form)
just continuing running even when the fill grid on the
grid-form is takeing a long time ...

Thanks and best regards
Frank Uray
 
F

Family Tree Mike

Patrice said:
At this point your best bet would be likely to reproduce the problem using
the minimal amount of code. Either you'll find what goes wrong yourself
during this process or if you are still stuck you'll be able to provide use
the *minimal* (you don't even need to read from a db, just do soemthign
costly to simulate the DataSet Fill process) amount of code that shows the
problem.

For now my understanding is that your UI thread is called from a background
thread each second to update some data.
Another background thread runs to load data (but the grid is updated just
one time once all data is returned ?)

I don't believe that he said this was done on another background thread
(loading the data). My read was this is being done on the UI thread,
hence blocking the "every second" update.

If the data load is done in a background worker, then the UI's (both)
should stay responsive.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top