Solved

Need to create background process to do DB management

Posted on 2003-12-03
3
329 Views
Last Modified: 2013-12-03
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.
0
Comment
Question by:hobster
3 Comments
 
LVL 10

Assisted Solution

by:smegghead
smegghead earned 50 total points
ID: 9871520
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.

Smg.
0
 
LVL 6

Accepted Solution

by:
townsma earned 75 total points
ID: 9878807
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.
0
 
LVL 2

Author Comment

by:hobster
ID: 10005885
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?
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now