Hi Everyone;
I have a bit of a problem with a Windows form application, when run the
application creates a worker thread to do the bulk of the socket
communication. On the form I have a timer control, which I want to be
able to use to to get the status of the thread.
Here is my code;
namespace IrcBot
{
public partial class IrcBot : Form
{
Thread myTObject;
IRCThread myIRC;
.........
private void btnConnect_Click(object sender, EventArgs e)
{
try
{
this.btnConnect.Enabled = false;
this.btnDisconnect.Enabled = true;
myIRC = new IRCThread(txtBotName, txtRealName,
txtServer, txtChannel, txtPort);
myTObject = new Thread(new
ThreadStart(myIRC.IRCFunctions));
myTObject.Name = "Micks Thread";
myTObject.Start();
}
catch (FormatException fEx)
{
// to do
}
catch (Exception ex)
{
// to do
}
}
private void timThread_Tick(object sender, EventArgs e)
{
toolStripStatusLabel1.Text = myTObject.IsAlive.ToString() ;
}
}
}
This doesnt display if the thread is running or not on the tool strip
ststus label.
Does anyone know where I am going wrong?