TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Carlo Marin
NA
5
0
SSH connection response not updating my GUI immediately
Sep 29 2010 10:42 AM
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
Reply
Answers (
2
)
Problem inserting textbox.text into Outlook Email
how to separate each word in a richtextbox content in c sharp