I have an IRC bot and I’m trying to create a new thread to do some work, the thread is called like this:
case ".showfiles":
if (!oThread.IsAlive)
{
say("#channel", "> shared files are:");
//a class called shares is in x.cs
SHARES SHARED = new SHARES();
/called a method named begin_find
oThread = new Thread(new ThreadStart(SHARED.begin_find));
oThread.IsBackground = true;
oThread.Start();
}
break;
the method that’s being called is simply scanning all files in a folder.
if the above code doesn’t provide enough info i’ll post the rest but basically as soon as I type .showfiles the bot disconnects with no error, almost like its taken place of the parent thread..
As the
ThreadisIsBackground = true, the application does not wait for it and terminates as soon as all foreground threads completed. If this is theMainmethod, the program might immediately terminate and therefore disconnect your bot.This is, however, a guess, since the context of your code is not obvious.