RelatedArticleNavigation
- SQL server2005 Transact-SQL new weapon learning Summary-Summary
- Index of flex and fms3 articles
- Flexair open-source edition-global free multi-person video chat room, free network remote multi-person Video Conferencing System (jointly developed by flex and fms3) <video chat, conference Development Instance 8>
Windows Services run in the background. It has no user interface and is suitable for processing tasks that do not interact with users. It can run on Windows, WINXP, WINNT, and other operating systems.
About how to write simple Windows service applications Program Can you refer to http://chs.gotdotnet.com/QuickStart/howto/default.aspx? Url =/Quickstart/howto/doc/simpleservice. aspx
Here, I made a small summary of my learning experience: Microsoft Windows Service uses system. serviceprocess space class to create, install, control where: class system. serviceprocess. servicebase is used to create a service class system. serviceprocess. serviceinstaller and system. serviceprocess. serviceprocessinstaller is used to install the service serviceinstaller class to extend servicebase to implement the service. When installing a service application, the installation utility calls serviceprocessinstaller to install an executable file that contains the class that extends servicebase. This class is called by the installation utility (such as installutil.exe) when installing the service application. Let's first understand several important attributes and methods of servicebase: Attributes
Servicename
Yes Service name attribute
Autolog
Yes Indicates whether to report the "Start", "stop", "pause", and "continue" commands in the event log. When this parameter is set to true, the system automatically reports status in the "application" event log.
Autolog Set
False,
We can process our own logs in the event
Attribute
Canstop
Yes Indicates whether the service can be stopped after it is started.
True
, The service can be stopped and the onstop method is called for the same attribute.
Canshutdown
And canpauseandcontinue
, Canshutdown
It is similar.
Virtual Method
Onstop
Yes When the Service receives the "stop" command, note that when
Canstop = false
Does not call this method
Virtual Method
Onstart
Yes Virtual method used by the Service to receive the "Start" command
Onpause
Yes When the Service receives the pause command (when the canpauseandcontinue attribute is true) virtual Method
Oncontinue
Yes When the service is "paused" and restarted (when the canpauseandcontinue attribute is true)
Virtual Method
Onshutdown
Yescomputer Virtual method that occurs when the system is disabled (when the canshutdown attribute is true)
Onpowerevent
Yes Virtual method executed when the computer power status changes (when the canhandlepowerevent attribute is true)
Oncustomcommand
Yes When executing a custom command Code Is implemented. You only need to repeat the preceding method in your code to implement the service attribute window of each service in your business logic point. You will find a "add installer" button, it is the Windows Service Installation function in vs2003. It actually generates an installation class, which inherits the system. configuration. install. after the installer is compiled, we get an EXE assembly and then use ". net Framework SDK installation utility "to install the service to our computer installation command: installutil.exe filename.exe reverse installation command: After the installutil.exe/u filename.exe service is installed, we can use the service control manager in the Windows Control Panel to control the running of our services. Of course, we can also write code to implement control. At this time, we need to use the class system. serviceprocess. servicecontroller, which is easy to use. For more information, see the help documentation. I wrote three applets for using Windows Services.
You can download
Code description in the compressed package: the transactionservice Project is a Windows service that implements a custom log and a custom performance counter, we first install this service. The transactionclient project uses a Win window to control this service. The servicecontroller project also uses a Win window to control this service.
Favorites and sharing
Add QQ bookmarks to Baidu souzang {
Function onclick ()
{
Window. Open ('HTTP: // myweb.cn.yahoo.com/popadd.html? Url = '+ encodeuricomponent (document. location. href) + '& Title =' + encodeuricomponent (document. title), 'yahoo ', 'scrollbars = Yes, width = 440, Height = 440, Left = 80, Top = 80, status = Yes, resizable = Yes ');
}
} "> Add to Yahoo favorites
RSS subscribe to me What is RSS?
Dongguan. Net Club
Welcome to join