Created
September 10, 2015 12:09
-
-
Save TerribleDev/2e81681da997b5352bd8 to your computer and use it in GitHub Desktop.
This file contains 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 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