Example #1
0
        private void SendScheduledTweets()
        {
            var copyList = new List<TwitterStatusTask>(Config.TweetTasks);
            AutoResetEvent waitHandle = new AutoResetEvent(false);
            int tasks = copyList.Count;
            foreach (TwitterStatusTask task in copyList)
            {
                Config.TweetTasks.Remove(task);
                var executor = new TaskExecutor(task);
                executor.Completed += (sender, e) => waitHandle.Set();
                executor.Error += (sender, e) =>
                {
                    Config.TweetTasks.Add(task);
                    Config.SaveTweetTasks();
                    waitHandle.Set();
                };
                executor.Execute();

                waitHandle.WaitOne(TimeSpan.FromSeconds(1)); // Do work sequentially
            }
            Config.SaveTweetTasks();
        }
Example #2
0
 void SendScheduledTweets()
 {
     var copyList = new List<TwitterStatusTask>(Config.TweetTasks);
     foreach (TwitterStatusTask task in copyList)
     {
         Config.TweetTasks.Remove(task);
         var executor = new TaskExecutor(task);
         executor.Completed += (sender, e) => SignalThreadEnd();
         executor.Error += (sender, e) =>
             {
                 Config.TweetTasks.Add(task);
                 Config.SaveTweetTasks();
                 SignalThreadEnd();
             };
         SignalThreadStart();
         executor.Execute();
     }
     Config.SaveTweetTasks();
 }