C#
  Home arrow C# arrow Creating a Windows Service with C#, contin...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C#

Creating a Windows Service with C#, continued
By: David Fells
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 38
    2006-03-07

    Table of Contents:
  • Creating a Windows Service with C#, continued
  • Creating the Windows Service Project
  • Coding the Service
  • Installing the Service

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Creating a Windows Service with C#, continued


    (Page 1 of 4 )

    This article, the second in a three-part series, covers what you need to do to convert a console application into a Windows Service and install it.



    The Zip file containing the source code for this and the other parts of this series can be found HERE.

    In the first part of this series we created a rudimentary TCP server that gives out the current date and time. In this article we will convert that console application into a Windows Service and install it. The transition will be mostly painless but there are a few considerations.

    First, we cannot rely on a keypress to stop our server anymore. We will have to implement the OnStop() method for the service, which is called implicitly when Windows attempts to stop a service. Second, we need some way to know that the server is working without having to run the test client all the time, so we will add code to the server to log to a custom Windows Event Log.

    We will address all these things in this article. In the third and final article, we will create a Windows Form application to run in the system tray that will allow us to stop and start the server. We will also add pause and continue functionality, which is a lot simpler than it sounds! For now, though, we will concern ourselves with getting the service built and installed.

    More C# Articles
    More By David Fells


       · Thanks for reading!
       · I read this article as I was doing a similar thing to make a Quote of the day...
       · Hi,I followed this article in creating the windows service but it hangs. I...
       · I'm seeing the same problem, has any come up with a fix? It will not shutdown until...
       · Now I am not certain what the exact way to do this is in C#/.NET, however in Java...
       · Pls Could you tell me how can I use .Net 2005 with this project. I can,t find some...
       · Close the socket from the OnStop and any waiting operation on that socket will...
     

    C# ARTICLES

    - C# Meets Design Patterns
    - Coding a CRC-Generating Algorithm in C
    - Cyclic Redundancy Check
    - Handling Methods and Functions
    - Destroying Objects in C#
    - Creating Objects in C-Sharp
    - Classes and Objects
    - Programming Languages: Managed versus Native
    - LINQ-to-MySQL with DbLinq in C#
    - Working with Dates and Times in C#
    - Generics, Dictionaries, and More
    - More About Generics
    - Working with C# Collections
    - Generics
    - C# and XML





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek