.NET threading solution for long queries
Posted
by Eddie
on Stack Overflow
See other posts from Stack Overflow
or by Eddie
Published on 2010-06-10T21:16:53Z
Indexed on
2010/06/10
21:33 UTC
Read the original article
Hit count: 344
Senerio
We have an application that records incidents. An external database needs to be queried when an incident is approved by a supervisor. The queries to this external database are sometimes taking a while to run. This lag is experienced through the browser.
Possible Solution
I want to use threading to eliminate the simulated hang to the browser. I have used the Thread
class before and heard about ThreadPool
. But, I just found BackgroundWorker
in this post.
The BackgroundWorker class allows you to run an operation on a separate, dedicated thread. Time-consuming operations like downloads and database transactions can cause your user interface (UI) to seem as though it has stopped responding while they are running. When you want a responsive UI and you are faced with long delays associated with such operations, the BackgroundWorker class provides a convenient solution.
Is BackgroundWorker
the way to go when handling long running queries?
What happens when 2 or more BackgroundWorker
processes are ran simultaneously? Is it handled like a pool?
© Stack Overflow or respective owner