Пример #1
0
 private static void TimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
 {
     try
     {
         timer.Stop();
         TweeterWorker ts = new TweeterWorker();
         ts.GetAndPublish();
     }
     catch (Exception ex)
     {
         File.AppendAllText("errorlog.txt", ex.Message);
     }
     finally
     {
         timer.Start();
     }
 }
Пример #2
0
        private async Task RunAsync(CancellationToken cancellationToken)
        {
            // TODO: Replace the following with your own logic.
            while (!cancellationToken.IsCancellationRequested)
            {
                Trace.TraceInformation("Working");

                try
                {
                    TweeterWorker ts = new TweeterWorker();
                    ts.GetAndPublish();
                }
                catch (Exception ex)
                {
                    File.AppendAllText("errorlog.txt", ex.Message);
                }



                await Task.Delay(TimeSpan.FromMinutes(1));
            }
        }