Skip to content

Instantly share code, notes, and snippets.

@TerribleDev
Created September 10, 2015 12:09
Show Gist options
  • Save TerribleDev/2e81681da997b5352bd8 to your computer and use it in GitHub Desktop.
Save TerribleDev/2e81681da997b5352bd8 to your computer and use it in GitHub Desktop.
public partial class Service1 : ServiceBase
{
private Timer timer = new Timer(300000);
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
Tick();
timer.Elapsed += timer_Elapsed;
timer.Start();
}
protected override void OnStop()
{
}
private static void timer_Elapsed(object sender, ElapsedEventArgs e)
{
Tick();
}
private static void Tick()
{
if (DateTime.Now.TimeOfDay > new TimeSpan(4, 0, 0) && DateTime.Now.TimeOfDay < new TimeSpan(21, 0, 0))
{
try
{
var t = WebRequest.Create("http://galbot.herokuapp.com");
t.Timeout = int.MaxValue;
var s = t.GetResponse();
}
catch
{
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment