pbraun wrote:
it seems that it would be better to send one query to the DB that retrieves all of the necessary data from the DB, then do the processing (in your case, calculations).
I'm afraid that it is not possible in my case, my condition is already complex enough at each loop :((, also it depends on some data outside the loop ...
pbraun wrote:
the constant queries to the DB is costing you the time
Yes, the queries are costing much of the time! I would like to ask also does the .NET framework do anything behind the scene when a long operation is in run? I have encountered a warning when "another" long operation was running: The CLR has been unable to transition from COM context 0x1a2008 to COM context 0x1a2178 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations. Thanks for your help Phil, I really appreciate it :-D