Click here to Skip to main content
15,891,758 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi folks,

we have a dashboard application that presents data according to dynamically executed SQL read from a database.

Up to now application connects to the database, loops against the grids (that present data), reads their SQL source, executes the SQL, presents the results in DataGridViews and then goes to next grid.

This is ok with few fast-responding grids but now we 've come up to a situation that from the moment that the user clicks the application to open until the window (fully loaded with data) is actually shown takes 2 - 3 mins.

Initially, I thought that solution is to put a "BackgroundWorker", for each run of this loop, in the background so that window pops-up immediately after the user starts the application and grids are presented as soon as they are fully loaded.

The tricky thinks here are:
1. the code that the thread needs to run is a dynamically build SQL which is not known at compile time so no "DoWork()" function can be written.

2. Even more, the number of grids is unknown at compile time so no effective number of threads that need to be used can be guessed in order for them to be declared.

Any ideas on how this should be treated in terms of architecture?

Is the "BackGroundWorker" the way to go?

Thanks in advance,
Nick Panoussis
Posted

1 solution

Reading at your question, the first thing that come to my mind is multi-threading. Backgroundworker is threading too but you cannot effectively have more than one threads at a time.

Create your own threads and by doing this you can dynamically add more threads as needed. Creating own threads is almost like Backgroundworkers. Try looking at projects about multi-threading on Code Project.

I managed to do this(multi-threaded process) myself by creating classes that will run as threads. I can control the amount of threads need to be run and also being as classes we can set properties that can be set during running time.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900