SunQuest
 
       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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
Moblin 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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: 5 stars5 stars5 stars5 stars5 stars / 24
    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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    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

    - Color Transformation in C# GDI+ Programming
    - Exceptions in C#
    - Overriding versus Overloading
    - Value Types and Reference Types
    - Defining Member and Type Visibility
    - Managing Files in C#
    - Working with Windows Registry in C#
    - Lossless Image Resizing in C#
    - Lossless Image Converting in C#
    - Creating an RSS Feed with ASP.Net Written in...
    - Polymorphism in C#
    - Inheritance in C#
    - C# Events Explained
    - C# Delegates Explained
    - C# StreamReader and StreamWriter Explained





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway