473,378 Members | 1,140 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Services and Service timers

Hi all

just a quick question. I have a windows service with a "Catalogue" class.

I would like to know: if i put two "ServiceTimer" objects in my service
1. Do they run in separate threads (i have never threaded before, so
excuse my ignorance)
2. If i have instances of the catalogue class in both those timers, will
there be an error?
for example, if Timer1 loops every 10 mins, and Timer2 loops every 3
minutes, if at any one time they overlap, would it throw an exception?
3. Should I have a global variable for my catalogue class instance, or
should they be local to each timer?

Thanks
Jason
Nov 16 '05 #1
1 1660
Hi Jason,

To the best of my knowledge, Service Timers just queue the specified event
handler to be called by a thread from the thread pool. Therefore, you can
have multiple service timers as long as your thread pool has enough free
threads to serve all timer handlers. This is my answer to #1 and #2.

As for #3, you can have a single instance of the Catalogue class, but this
instance should be thread-safe. This at least means all access to the
instance members should be protected with the "lock" statement.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Jason" <c_*******@mighty.co.za> wrote in message
news:u0**************@tk2msftngp13.phx.gbl...
Hi all

just a quick question. I have a windows service with a "Catalogue" class.

I would like to know: if i put two "ServiceTimer" objects in my service
1. Do they run in separate threads (i have never threaded before, so
excuse my ignorance)
2. If i have instances of the catalogue class in both those timers, will there be an error?
for example, if Timer1 loops every 10 mins, and Timer2 loops every 3 minutes, if at any one time they overlap, would it throw an exception?
3. Should I have a global variable for my catalogue class instance, or
should they be local to each timer?

Thanks
Jason


Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Niyazi | last post by:
Hi, I have BIG question and I gues it is the BEST question. I have a problem that I am guessing the best solution is to create some sort ..NET Services. This Service(s) must check every...
0
by: Paul James | last post by:
Hi. I'm having difficulty using a System.Net.HttpWebRequest/Response from a multithreaded c# windows service. My service is creating several System.Threading.Timers at startup and then...
8
by: Paul.Hawkes | last post by:
Hello, I've written a windows service and so far what it does is browse to a shared directory on an extranet. Check to see if any files exist in this folder, if any do, the service downloads,...
1
by: jeff | last post by:
Greetings; Newbie here, please forgive my ignorance of the vb.net threading model. I am developing a windows service which is driven by a variable number of timers. All timers use the same...
2
by: jeff | last post by:
Greetings; Newbie here, please forgive my ignorance of the vb.net threading model. I am developing a windows service which is driven by a variable number of timers. All timers invoke the same...
5
by: Eric | last post by:
Hi I built a service that watch file in a directory. I use a simple filewatcher and add a handler to do something when a file is created. I have the following problem. I can build it, I can...
2
by: sdstraub | last post by:
I have created 5 services in my project, in the 1st service I set servicestorun = array of all 5 services, I have a project installer with 5 service installers, one for each service. I have code...
0
by: Jason | last post by:
Ok, for the life of me, I just don't understand what's going on. I want to use remoting to send messages from a windows service to a windows form app, but I just can't get it to work. So, here's...
4
by: Tomas Andersson | last post by:
I have two questions regarding services. First of. Is there any problem with creating VB9 services running timer events om Winxp? I built a service App and it installs and runs but the timer...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.