Need to create background process to do DB management

I'll give more points for the right answer.

I want to create a Windows app in C# that does some simple DB stuff, such as adding a new employee. When this program starts, it also creates another thread(?) that periodically accesses the database (ex. sql server) and does some stuff to it. This background process would wake up every 10 min, for example, does what it needs to do, then goes to sleep for 10 min. The process has to run asynchronously to the main app.

What I'm looking for is a prototype of this main app/background process. Thanks.
Who is Participating?
townsmaConnect With a Mentor Commented:
To take the recomendation of smegghead one stage further, try creating a thread at a module level, then when the timer event fires, check the state of the thread, if still running, exit the sub.  If not still running start the thread.  This way you db work will still run in a seperate thread.

Hope this helps, good luck.
smeggheadConnect With a Mentor Commented:
Why not just use a timer?? that way you don't have to bother with creating/starting threads.

Just put a timer on your form and add your code to check the sql.

hobsterAuthor Commented:
Do threads run asynchronously of each other? I read that they don't. One thread runs for a bit, then stops and another thread runs and stops and the 1st one runs again. It's not true multitasking. Is there a way to make them both run at the same time?
All Courses

From novice to tech pro — start learning today.