I am only creating the form once. I'm calling the log procedure from a different thread then the main thread which the text box was created in thats a problem. As you can see by my code if the handle for the text box is created then I should have no problem, how do I create a handle for my text box.
Ok I think I figured something out here.
public void Log(string Text)
{
string CurTime;
Form1 myForm = new Form1();
if (myForm.textBox1.InvokeRequired == true)
{
MessageBox.Show("TEST");
//We're not in the UI thread, so we need to call BeginInvoke...
Ok I set up my log function like this:
public void Log(string Text)
{
string CurTime;
Form1 myForm = new Form1();
if (myForm.textBox1.InvokeRequired)
{
myForm.textBox1.BeginInvoke(new StringParameterDelegate(Log), new object[] { Text });
return;
}...
public void button1_Click(object sender, EventArgs e)
{
ThreadStart job = new ThreadStart(Connection.Start);
Thread thread = new Thread(job);
thread.Start();
}
Calls the procedure Start() which is located in the same class, but using a...
Yes it is on a diffrent thread is that the problem?. I'm running a constant loop which processes the information taken from telent as this is a telnet server. And it would freeze my main form so I ran it in a diffrent thread.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.