home *** CD-ROM | disk | FTP | other *** search
-
- <!-- #include virtual="/quickstart/howto/include/header.inc" -->
-
- <h4>How Do I...Write a simple service application?</h4>
-
- <div class="indent" style="width:660"><font face="Tahoma" size="1">
-
- <p>Microsoft Windows NT services enable you to create long-running executable applications
- that run in their own Windows sessions. These services can be automatically started when
- the computer boots, can be paused and restarted, and typically do not show any user
- interface. This makes services ideal for use on a server or whenever you need long-running
- functionality that does not interfere with other users who are working on the same computer.
- You can also run services in the security context of a specific user account that is
- different from the logged-on user or the default computer account. For more information
- about services and Windows sessions, see the "About Services" section in the
- Platform SDK documentation in MSDN Online.</p>
-
- <p>Using the NGWS framework, you can easily create services by creating an application that
- is installed as a service. For example, suppose you want to monitor performance counter data
- and react to threshold values. You could do this by writing an NT service and deploying it
- to the computer that has the counters you want to monitor.</p>
-
- <p>This sample is such a simple service application. You can install it using the NGWS SDK
- Installation Utility. From a command prompt run:</p>
-
- </font><font face="Courier New" color="Blue" size="1"><blockquote>
- > InstallUtil.exe SimpleService.exe
- </blockquote></font><font face="Tahoma" size="1">
-
- <p>After the installation is completed you can start the Hello-World Service from the
- Services Management Console. After the service starts you should see the service's event
- log being filled with greetings from the sample service. You can use the Services
- Management Console to pause, continue, start, and stop the service, and observe how such
- operations affect the messages written to the event log. After you are done experimenting
- with the sample, you may uninstall the service by running the following command from the
- command window (you should stop the service before uninstalling it):</p>
-
- </font><font face="Courier New" color="Blue" size="1"><blockquote>
- > InstallUtil.exe /u SimpleService.exe
- </blockquote></font><font face="Tahoma" size="1">
-
- </font></div>
-
- <h4>Example</h4>
-
- <div class="indent">
- [<a target="_blank" href="/quickstart/util/srcview.aspx?path=/quickstart/howto/samples/Services/ServiceApplication/SimpleService/SimpleService.src">View Source</a>]
- </div>
-
- <h4>Source Code</h4>
-
- <div class="code">
- <xmp>
- <!-- #include virtual="/quickstart/howto/samples/Services/ServiceApplication/SimpleService/SimpleService.cs" -->
- </xmp>
- </div>
-
- <!-- #include virtual="/quickstart/howto/include/footer.inc" -->