mfc >> service - how to install a timer?

by Philipp Huber » Fri, 28 Nov 2003 16:08:45 GMT

hi!

which is the best (common) way to install something like a timer within a
service?

as everybody says using sleep was a poor thing (i agree) i am not sure how
to achieve this.

should i create a helper window that provides a timer?
is it possible at all to use a helper window when the flag
SERVICE_INTERACTIVE_PROCESS is not set?

thanks philipp




mfc >> service - how to install a timer?

by Frank Hickman » Fri, 28 Nov 2003 16:26:09 GMT


Timers depend on a windows message pump. You do not need to actually have a
window to have a message pump but it is normal to do so. You may want to
consider using WaitForSingleObject or WaitForMultipleObjects, it really
depends on what your trying to accomplish. If you could provide some
additional information in that regard, I am sure someone here could suggest
multiple ways to accomplish it.

--
============
Frank Hickman
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.










mfc >> service - how to install a timer?

by Philipp Huber » Fri, 28 Nov 2003 16:55:03 GMT

> If you could provide some
suggest

i'd like to write a service that collects data of particle sensors in a
certain cycle (i.e. every 10 secounds).

furthermore i'd like to avoid using code like:

[...]
while( m_bServiceIsRunning )
{
DoCollectData();

Sleep( 1000 );
}
[...]

in my ServiceMain function.

instead of this i'd like to have a CMultiLock waiting on either a terminate
event or a timer event.

thanks philipp




service - how to install a timer?

by Chris Mabey » Fri, 28 Nov 2003 17:23:51 GMT

Alternatively there are the multimedia timers which are very accurate see
timeSetEvent in the MSDN.

Chris



terminate




service - how to install a timer?

by Scott McPhillips [MVP] » Fri, 28 Nov 2003 18:54:53 GMT





CMultiLock does not support the full capabilities of
WaitForMultipleObjects. Use WaitForMultipleObjects with a timeout
parameter.

--
Scott McPhillips [VC++ MVP]



service - how to install a timer?

by Philipp Huber » Fri, 28 Nov 2003 19:13:08 GMT

thanks a lot.

philipp




Similar Threads

1. Services and Service timers - CSharp/C#

2. TransactedInstaller.Install results in Service Already Installed

I am writing a service in C# with an internal service installer.

I am running XP Pro SP with VS7.1 and .NET 1.1

It installed okay the first time, but during uninstall the app crashed.

Now I am unable to install again:
Running a transacted installation.

Beginning the Install phase of the installation.
'FlightExchangeService.exe': Loaded 
'c:\windows\assembly\gac\system.windows.forms\1.0.5000.0__b77a5c561934e089\system.windows.forms.dll', No symbols loaded.
Installing service FlightExchanger...
Service FlightExchanger has been successfully installed.
Creating EventLog source FlightExchanger in log Application...
Installing service FlightExchanger...
Creating EventLog source FlightExchanger in log Application...

An exception occurred during the Install phase.
System.ComponentModel.Win32Exception: The specified service already exists

The service does not appear to Exist. I checked the services list in the 
service manager, and even enumerated through the SC Manager in code, but 
could not see my service.

I have searched the registry and removed its EventLog source by deleting the 
reg key. This appeared to have no effect.

I have spent all day today searching the net for solutions, and can find 
nothing.

Is anyone able to help?
-- 
Recursion: See Recursion

3. Windows Service Installer (service not showing up when installed) - CSharp / C#

4. Add/Remove Programs: The specified service does not exist as an installed service

5. Service install -- The specified service already exists - CSharp/C#

6. Service app installs but is not visible in service manager

Hi all,

maybe somebody can help me with a service installation problem in VS 
2003, C#.

First, I added an installer project to a solution with a program that 
shall run as a service. So far, so good, the program installs ok with 
the resulting msi file, is obviously registered as service and visible 
in the service manager.

For a second similiar service I created a new solution, likewise with 
program and installer project, and then copied most of the cs files from 
the first service to adapt them to the differences. When I create the 
msi file there, installation works (i.e. the files are installed), but I 
cannot see the service in the service manager (even after a reboot). So 
I cannot start it or do something else with it. When I use installUtil 
additionally everything is allright and the service displays in service 
manager.

Has somebody made a similar experience or does somebody have an idea 
what might be wrong there? I tried to find any relevant differences 
between the two solutions as well as inconvenient similarities (e.g. 
identical guids, or something like that) but I can't find why one 
installer works and the other not.

Any ideas appreciated! Thanks.
Regards
Roland

7. Array of System.Timers.timer - Assigning an object to timer - CSharp/C#

8. Launching Thread w/in a timer service

 From a Windows service (NET 2.0)  I want to launch serveral threads in 
a for loop that invokes a method using:

	new Thread(delegate()
         	{ myMethod(248);}).Start();


Will those threads stay active even when the service reaches it Service 
Timer Stop?

Do I have to create a thread monitor to test when those threads are 
finished before allowing the service to go to the next Timer_Tick?