Click here to Skip to main content
13,096,157 members (52,532 online)
Rate this:
Please Sign up or sign in to vote.
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 19-Oct-11 0:10am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 22 Oct 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100