timers [Delay without Freezing the app !] C# -
i'm trying make application every 10 minutes executes 10 different sql queries, , between each sql query there should short delay (for example, 1 second).
if try use thread.sleep(1000);
, other timers stop , whole application freezes.
any idea how without freezing application or stopping other timers?
you can use threading spin thread performs actions.
the simplest form system.threading.threadpool.queueuserworkitem(waitcallback)
it takes delegate consumes single object
, performs task.
e.g.
private void worker(object ignored) { //run first query thread.sleep(1000); //run second query etc. } //the following code want start process //for instance in response timer threadpool.queueuserworkitem(worker);
Comments
Post a Comment