private void Exec()
{
while (this.IsActive && Core.IsRunning)
{
try
{
this.Disconnect();
this.Connect();
while (!this.IsWorking && !this.Protocol.IsDisconnected)
{
// we need to wait for the irc handler to connect to irc
Thread.Sleep(100);
}
// now we can finally join all channels
Join();
// then we just sleep
while (this.Network.IsConnected)
{
Thread.Sleep(2000);
}
// in case we got disconnected, we log it and restart the procedure
Syslog.WarningLog("Disconnected from irc network on " + Nick);
Thread.Sleep(20000);
}
catch (ThreadAbortException)
{
Syslog.DebugLog("Terminated primary thread for instance " + Nick);
return;
}
catch (IOException fail)
{
if (this.IsActive)
{
Syslog.ErrorLog("Failure of primary thread of instance " + Nick + " attempting to recover");
Core.HandleException(fail);
}
else
{
return;
}
}
catch (Exception fail)
{
Core.HandleException(fail);
if (this.IsActive)
Syslog.ErrorLog("Failure of primary thread of instance " + Nick + " attempting to recover");
else
return;
Thread.Sleep(20000);
}
}
Core.ThreadManager.UnregisterThread(Thread.CurrentThread);
}