Click here to Skip to main content
Rate this: bad
good
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 1:10am

1 solution

Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 Marcin Kozub 275
1 OriginalGriff 249
2 Sergey Alexandrovich Kryukov 215
3 Praneet Nadkar 197
4 Richard MacCutchan 182
0 OriginalGriff 8,048
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 22 Oct 2011
Copyright © CodeProject, 1999-2014
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