static void MainLoop(CancellationToken token) { while (true) { // do something here. var email = new TurdMail(); var tweet = new TurdTweet(); //var email.CheckMail(); if (email.Notification) { //do a tweet tweet.DoTweet(email); } Thread.Sleep(1000 * 5); // Poll on this property if you have to do // other cleanup before throwing. if (token.IsCancellationRequested) { // Clean up here, then... //"cleanup".Dump(); token.ThrowIfCancellationRequested(); } } }
static void Main(string[] args) { var email = new TurdMail(); var tweet = new TurdTweet(); //var email.CheckMail(); if (email.Notification) { //do a tweet tweet.DoTweet(email); } }