
Originally Posted by
Nillus
Works nice, except for some reason it doesn't want to print the log in the textbox (while it does Msgbox it), and in the line under it I have txtLog.AppendText(THELOGSTUFF) but it simply won't write.
Probably something I don't know and it shouldn't be hard to solve, I guess it has to do with the fact that the data arrival sub is asynchronous and I'm calling back to a form from it. (have to invoke it first?)
I haven't downloaded the source, so i don't know if im right (But i probably am)
The reason it wont access a textbox is because your accessing it from another thread (If your using Asynchronous sockets - This is definitely the case)
There are a few quick solutions you can do, Either simply write it to a text file rather than to an actual textbox on your Form
OR use the invoke method
For example.. (C#)
Code:
internal delegate void A2L(string Txt);
internal void AddToLog(string Text)
{
if(this.InvokeRequired)
this.Invoke(new A2L(AddToLog),Text);
else
{
TxtLog.AppendText(Text);
}
}
Because you're accessing it from a separate thread it can't modify it properly and so an invoke is required.
Edit: And i'm guessing the reason it wont close is because your not Closing every form? (Or when they hit the X button your threads are still running - sockets etc)
just put this inside your 'Form Closing' event
System.Environment.Exit(0);
(If you don't know how to add events (Idk if you have to do this in VB.NET) but simply go to the form designer class
(Called FormName.Designer.cs)
And then scroll down to where its normally like
this.Load += new System.EventHandler(this.Form1_Load);
And shove in
this.FormClosing += new System.EventHandler(this.Form_Closing);
for example (Form_Closing) being the name of the method you've already created.
~ Jeax