Example #1
0
        /// <summary>
        /// Global program entry point.
        /// </summary>
        static void Main(string[] args)
        {
            Console.WriteLine("Initializing!");
            Configuration = new YAMLConfiguration(GetConfig());
            List <Task> tasks = new List <Task>();

            DiscordBot = new dDiscordBot();
            Task.Factory.StartNew(() => DiscordBot.Init(Configuration));
            foreach (string server in Configuration.GetKeys("dircbot.irc-servers"))
            {
                Console.WriteLine("Preparing server: " + server);
                tasks.Add(Task.Factory.StartNew(() =>
                {
                    dIRCBot core = new dIRCBot();
                    lock (presentBotsLock)
                    {
                        PresentBots.Add(core);
                    }
                    core.ServerName = server;
                    core.Init();
                }));
            }
            while (tasks.Count > 0)
            {
                for (int i = 0; i < tasks.Count; i++)
                {
                    if (tasks[i].IsCompleted)
                    {
                        tasks.RemoveAt(i--);
                    }
                }
                Thread.Sleep(100);
            }
            Logger.Output(LogType.INFO, "Quitting cleanly.");
        }
 /// <summary>
 /// Global program entry point.
 /// </summary>
 static void Main(string[] args)
 {
     Console.WriteLine("Initializing!");
     Configuration = new YAMLConfiguration(GetConfig());
     List<Task> tasks = new List<Task>();
     DiscordBot = new dDiscordBot();
     Task.Factory.StartNew(() => DiscordBot.Init(Configuration));
     foreach (string server in Configuration.GetKeys("dircbot.irc-servers"))
     {
         Console.WriteLine("Preparing server: " + server);
         tasks.Add(Task.Factory.StartNew(() =>
         {
             dIRCBot core = new dIRCBot();
             lock (presentBotsLock)
             {
                 PresentBots.Add(core);
             }
             core.ServerName = server;
             core.Init();
         }));
     }
     while (tasks.Count > 0)
     {
         for (int i = 0; i < tasks.Count; i++)
         {
             if (tasks[i].IsCompleted)
             {
                 tasks.RemoveAt(i--);
             }
         }
         Thread.Sleep(100);
     }
     Logger.Output(LogType.INFO, "Quitting cleanly.");
 }