473,388 Members | 1,355 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,388 software developers and data experts.

controlling windows service start and stop (shutdown) timeout

Hello,

Is there some way to control SCM timeout while starting or stopping a C#
windows service? I know I can work on a different thread and quickly return
from OnStart(), but I'd like my service to shutdown gracefully, and it takes
a long time to save all data while exiting.

Thanks for any help,
Jan
Nov 22 '05 #1
3 4856
Jan Waga wrote:
Hello,

Is there some way to control SCM timeout while starting or stopping a C#
windows service? I know I can work on a different thread and quickly return
from OnStart(), but I'd like my service to shutdown gracefully, and it takes
a long time to save all data while exiting.

Thanks for any help,
Jan


There is a way in the Win SDK which .NET uses.
Part of the low level API provides a way for your service to HINT to the
SCM.

But .NET does not expose this (and a lot of other useful features!).

If .NET would ALSO expose its internal SCM handle, then you could call
WIN32 directly for the places it falls short.

I'm with you, I think all of this wonderful stuff should be there.

- Lee
Nov 22 '05 #2
Thank you, yesterday I found your post on DotNetMonster (or similar NET
portal, I don't recall). I guess I have to write ordinary C++ service and
call a process.

Jan
Nov 22 '05 #3

"Lee Gillie" <Le*@nospam.odp.com> wrote in message
news:er**************@TK2MSFTNGP10.phx.gbl...
Jan Waga wrote:
Hello,

Is there some way to control SCM timeout while starting or stopping a C#
windows service? I know I can work on a different thread and quickly
return
from OnStart(), but I'd like my service to shutdown gracefully, and it
takes
a long time to save all data while exiting.

Thanks for any help,
Jan


There is a way in the Win SDK which .NET uses.
Part of the low level API provides a way for your service to HINT to the
SCM.

But .NET does not expose this (and a lot of other useful features!).

If .NET would ALSO expose its internal SCM handle, then you could call
WIN32 directly for the places it falls short.

I'm with you, I think all of this wonderful stuff should be there.

- Lee


This is taken care of in v2.0 - see ServiceBase.RequestAdditionalTime(msecs)
method.
This method will hint the SCM to wait for additional msecs. time before it
decides a start/stop ... pending request failed.

Willy.

Nov 22 '05 #4

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

Similar topics

3
by: Jan Waga | last post by:
Hello, Is there some way to control SCM timeout while starting or stopping a C# windows service? I know I can work on a different thread and quickly return from OnStart(), but I'd like my...
2
by: Simon Niederberger | last post by:
Hi I've written a Windows Service which has - several (0-100) listeners threads which spawn worker threads based on events, timers etc - several (0-300) worker threads which handle data...
2
by: 0to60 | last post by:
I have a windows service that when started creates two threads: one thread that runs a TcpListener waiting for TcpClients to connect, and another thread that reads from the resulting sockets. My...
1
by: JDF | last post by:
I am fairly new to python and seem to have gotten ahead of myself. I am trying to write a Windows service that will return the current number of Citrix sessions to a client. This service will run...
3
by: belgiozen | last post by:
Hi, I have a working windows service,it is looking for files on the disk and when some of the files are cupdated it calls an executable. But it takes a lot of time(about 10 minutes) to run the...
5
by: Richard Steele | last post by:
I have created a WinForm application that needs to be run as a windows service (the PC is inaccesible by any user) i have successfully installed the application as a windows service. When i start...
6
by: D | last post by:
I have a simple file server utility that I wish to configure as a Windows service - using the examples of the Python Win32 book, I configured a class for the service, along with the main class...
6
by: Ash | last post by:
Hi coders, I have a service that does alot of data copying to the database and when the service is stopped or the machine is shutting down it commits the data (in addition to other things) and...
4
by: jez123456 | last post by:
Hi Experts I've written a c# windows service which runs another program at certain intervals. The other program may take upto 20 minutes to complete it's tasks. My question is what happens to...
10
by: tshad | last post by:
I have a Windows Service that I need to put to sleep for about 10-20 minutes. The problem is that if you try to shut it down during this time, it will tell you that the service didn't respond in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.