SSH connection response not updating my GUI immediately
Hi Guys,
I'm pretty new to Threading and delegates, I've got this simple little app that I was working on just to learn to use the SharpSSH library in my larger application. I wanted to get an active update to a rich text box that i have on my form everytime I i get a response from sending a runCommand method my RTB only seems to update when the sshexec connection is closed any tips or steering me in the right direction would be greatly appreciated :).
What i find a little strange is that it will write to the console but not to the RTB...
below is my class:
namespace ThreadedApplicationTest
{
public partial class Form1 : Form
{
SshExec myShellExecutor = new SshExec("xxx.xxx.xxx.xxx","xx","xxxxx");
string result = "";
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
myShellExecutor.Connect();
result = myShellExecutor.RunCommand("ls");
Console.WriteLine(result);
richTextBox1.Invoke((ThreadStart)delegate() { updateRTB(result); });
result = myShellExecutor.RunCommand("hostname");
myShellExecutor.Close();
}
private void updateRTB(String s)
{
richTextBox1.AppendText(s);
}
}
}
Thanks!
Carlo