@@ -11,7 +11,7 @@ void MainOriginal()
1111 //<Snippet6>
1212 System . ServiceProcess . ServiceBase [ ] ServicesToRun ;
1313 ServicesToRun = new System . ServiceProcess . ServiceBase [ ]
14- { new Service1 ( ) } ;
14+ { new Service1 ( ) } ;
1515 System . ServiceProcess . ServiceBase . Run ( ServicesToRun ) ;
1616 //</Snippet6>
1717 }
@@ -20,60 +20,60 @@ void MainOriginal()
2020
2121public class MyNewService : System . ServiceProcess . ServiceBase
2222{
23- //<Snippet1>
23+ //<Snippet1>
2424 static void Main ( )
2525 {
2626 System . ServiceProcess . ServiceBase [ ] ServicesToRun ;
2727 // Change the following line to match.
2828 ServicesToRun = new System . ServiceProcess . ServiceBase [ ]
29- { new MyNewService ( ) } ;
29+ { new MyNewService ( ) } ;
3030 System . ServiceProcess . ServiceBase . Run ( ServicesToRun ) ;
3131 }
3232 //</Snippet1>
33-
3433
3534
36- //<Snippet16>
37- private System . ComponentModel . IContainer components ;
38- private System . Diagnostics . EventLog eventLog1 ;
39- //</Snippet16>
35+ //<Snippet16>
36+ private System . ComponentModel . IContainer components ;
37+ private System . Diagnostics . EventLog eventLog1 ;
38+ //</Snippet16>
4039
41- [ System . Diagnostics . DebuggerStepThrough ( ) ]
42- void InitializeComponent ( )
43- {
44- components = new System . ComponentModel . Container ( ) ;
45- this . ServiceName = "MyNewService" ;
46- }
4740
48-
49- //<Snippet2>
41+ [ System . Diagnostics . DebuggerStepThrough ( ) ]
42+ void InitializeComponent ( )
43+ {
44+ components = new System . ComponentModel . Container ( ) ;
45+ this . ServiceName = "MyNewService" ;
46+ }
47+
48+
49+ //<Snippet2>
5050 public MyNewService ( )
5151 {
5252 InitializeComponent ( ) ;
5353 eventLog1 = new System . Diagnostics . EventLog ( ) ;
5454 if ( ! System . Diagnostics . EventLog . SourceExists ( "MySource" ) )
5555 {
56- System . Diagnostics . EventLog . CreateEventSource (
57- "MySource" , "MyNewLog" ) ;
56+ System . Diagnostics . EventLog . CreateEventSource (
57+ "MySource" , "MyNewLog" ) ;
5858 }
5959 eventLog1 . Source = "MySource" ;
6060 eventLog1 . Log = "MyNewLog" ;
6161 }
62- //</Snippet2>
62+ //</Snippet2>
63+
6364
64-
65- //<Snippet3>
65+ //<Snippet3>
6666 protected override void OnStart ( string [ ] args )
6767 {
68- eventLog1 . WriteEntry ( "In OnStart" ) ;
68+ eventLog1 . WriteEntry ( "In OnStart. " ) ;
6969 }
7070 //</Snippet3>
7171
7272
7373 //<Snippet4>
7474 protected override void OnStop ( )
7575 {
76- eventLog1 . WriteEntry ( "In onStop ." ) ;
76+ eventLog1 . WriteEntry ( "In OnStop ." ) ;
7777 }
7878 //</Snippet4>
7979
@@ -99,70 +99,70 @@ public class UserService1 : System.ServiceProcess.ServiceBase
9999//*******************************************************************
100100namespace WrapUserService1
101101{
102- public class UserService1 : System . ServiceProcess . ServiceBase
103- {
104- //<Snippet8>
105- public UserService1 ( )
102+ public class UserService1 : System . ServiceProcess . ServiceBase
106103 {
107- this . ServiceName = "MyService2" ;
108- this . CanStop = true ;
109- this . CanPauseAndContinue = true ;
110- this . AutoLog = true ;
111- }
112- //</Snippet8>
104+ //<Snippet8>
105+ public UserService1 ( )
106+ {
107+ this . ServiceName = "MyService2" ;
108+ this . CanStop = true ;
109+ this . CanPauseAndContinue = true ;
110+ this . AutoLog = true ;
111+ }
112+ //</Snippet8>
113113
114114
115- //<Snippet9>
116- public static void Main ( )
117- {
118- System . ServiceProcess . ServiceBase . Run ( new UserService1 ( ) ) ;
119- }
120- //</Snippet9>
115+ //<Snippet9>
116+ public static void Main ( )
117+ {
118+ System . ServiceProcess . ServiceBase . Run ( new UserService1 ( ) ) ;
119+ }
120+ //</Snippet9>
121121
122122
123- //<Snippet10>
124- protected override void OnStart ( string [ ] args )
125- {
126- // Insert code here to define processing.
123+ //<Snippet10>
124+ protected override void OnStart ( string [ ] args )
125+ {
126+ // Insert code here to define processing.
127+ }
128+ //</Snippet10>
127129 }
128- //</Snippet10>
129- }
130130}
131131
132132
133133//*******************************************************************
134134class UserService2 : System . ServiceProcess . ServiceBase
135135{
136- System . Diagnostics . EventLog eventLog1 ;
136+ System . Diagnostics . EventLog eventLog1 ;
137137
138- //<Snippet14>
138+ //<Snippet14>
139139 public UserService2 ( )
140140 {
141- eventLog1 = new System . Diagnostics . EventLog ( ) ;
141+ eventLog1 = new System . Diagnostics . EventLog ( ) ;
142142 // Turn off autologging
143+
143144 //<Snippet17>
144145 this . AutoLog = false ;
145146 //</Snippet17>
146147 // create an event source, specifying the name of a log that
147148 // does not currently exist to create a new, custom log
148149 if ( ! System . Diagnostics . EventLog . SourceExists ( "MySource" ) )
149- {
150- System . Diagnostics . EventLog . CreateEventSource (
151- "MySource" , "MyLog" ) ;
150+ {
151+ System . Diagnostics . EventLog . CreateEventSource (
152+ "MySource" , "MyLog" ) ;
152153 }
153154 // configure the event log instance to use this source name
154155 eventLog1 . Source = "MySource" ;
155- eventLog1 . Log = "MyLog" ;
156+ eventLog1 . Log = "MyLog" ;
156157 }
157- //</Snippet14>
158+ //</Snippet14>
158159
159160
160- //<Snippet15>
161-
161+ //<Snippet15>
162162 protected override void OnStart ( string [ ] args )
163163 {
164164 // write an entry to the log
165165 eventLog1 . WriteEntry ( "In OnStart." ) ;
166166 }
167167 //</Snippet15>
168- }
168+ }
0 commit comments