TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
carl_sargunar
NA
1
0
Thread Pool with windows service
Aug 14 2008 10:26 AM
Hi
I was wondering the best way to implement a multi threaded windows service, to be used in similar fashion to the windows task scheduler service with added functionality.
Does anybody know of any resources or can anybody point me inthe right direction. I so far plan to have a main thread running as part of a threadpool, and each time I need to start a new task, start a new thread and add it to the thread pool. I assume then the task has finished, the thread will automatically stop and be removed from the threadpool.
Stopping the service will stop any subsequent threads from starting, using simple bool flags, but not stop any threads already running from finishing
Pseudocode would be something like this
Thread main = new thread()
Bool running;
OnStart()
{
running = true;
main.threadstart = MainThreadWorker;
main.start;
}
OnStop() { running = false; }
MainThreadWorker()
{
while (running)
{
If (new task)
{
Start New thread;
Add new thread to Threadpool;
}
if (running) {mainthread.sleep (Some interval)}
}
Somehow kill the threadpool here;
}
thanks for your help
Reply
Answers (
1
)
automation tool for ui developed in sharepoint with silverlight components
API access to existing instance of a program