Okay i have a little problem here.

I have a ping class as such

Code:
using System;
using System.Net.Sockets;
using System.Threading;
using z3r0xB0t;
using BOT;

class Ping
{
    public static void Run()
    {
        while (true)
        {
            try
            {
                BotMain.writer.WriteLine("PONG :" + Config.SERVER);
                BotMain.writer.Flush();
            }
            catch (Exception)
            {
                BotMain.irc = new TcpClient();
                Thread.Sleep(8000);
                BotMain.Main(null);
            }
            Thread.Sleep(12000);
        }
    }
}
and the beginning connection in the main module is as such

Code:

Code:
NetworkStream stream;
string inputLine;
StreamReader reader;
Boolean logged = false;
String cuser = "./*&$%^";
try
{
    irc = new TcpClient(Config.SERVER, Config.PORT);
}
catch (Exception) { irc = new TcpClient(); Main(null); }
stream = irc.GetStream();
reader = new StreamReader(stream);
writer = new StreamWriter(stream);
writer.AutoFlush = true;
Thread ping = new Thread(new ThreadStart(Ping.Run));
ping.Start();
And at first it connects fine, but when i close my test server, and open it again, the bot won't automaticly reconnect.

any suggestions on what i am doing wrong here?

And is there any code to have them also check every x seconds if they are still in the channel and have them rejoin if they aren't?

thanks!