Created
February 21, 2011 00:54
-
-
Save cammerman/836488 to your computer and use it in GitHub Desktop.
Service does something once
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface IGreeter | |
| { | |
| void SayHello(); | |
| } | |
| public class Greeter : IGreeter | |
| { | |
| public Greeter () | |
| { | |
| } | |
| public void SayHello() | |
| { | |
| using (var helloStream = new FileStream(@"C:\Hello\World.txt", FileMode.Create, FileAccess.Write, FileShare.Read)); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace HelloSvc.Services | |
| { | |
| using Config; | |
| internal class GreetService : ServiceBase | |
| { | |
| protected virtual IGreeter Greeter | |
| { | |
| get; | |
| private set; | |
| } | |
| public GreetService(IServiceNameProvider serviceNameProvider, IGreeter greeter) | |
| { | |
| serviceNameProvider.ThrowIfNull("serviceNameProvider"); | |
| ServiceName = | |
| serviceNameProvider.ServiceName | |
| .ThrowIfNullOrEmpty("serviceNameProvider.ServiceName"); | |
| Greeter = greeter.ThrowIfNull("greeter"); | |
| CanStop = true; | |
| AutoLog = false; | |
| } | |
| protected override void OnStart(String[] args) | |
| { | |
| Greeter.SayHello(); | |
| } | |
| protected override void OnStop() | |
| { | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment