Skip to content

Instantly share code, notes, and snippets.

@cammerman
Created February 21, 2011 00:54
Show Gist options
  • Select an option

  • Save cammerman/836488 to your computer and use it in GitHub Desktop.

Select an option

Save cammerman/836488 to your computer and use it in GitHub Desktop.
Service does something once
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));
}
}
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