[Gtk-sharp-list] Gnome app + Shell Command + Threads

Lluis Sanchez lluis@ximian.com
Mon, 31 Jan 2005 20:56:09 +0100


You can only modify Gtk widgets from the GUI thread. You can use
GLib.Idle.Add() to dispatch work from a non-GUI thread to the GUI
thread.

On dl, 2005-01-31 at 20:28 +0100, Antonio GutiƩrrez Mayoral wrote:
> Hi All:
> 
> I have the next problem. I am writing a gnome app... and in a moment I
> launch a shell command. I would like to write the output of this command
> over a textview widget, at the same time the command is executed. I am
> using System.Threads to do this, 
> 
> 	Thread t = new Thread ( new ThreadStart( this.process_ ) ) ;
> 	t.Start();	
> 
> And I read the standard output in the shell process, 
> 
> 	p.StartInfo.UseShellExecute = false;
> 	p.StartInfo.RedirectStandardOutput = true;
> 	p.StartInfo.RedirectStandardInput = true;
> 	p.StartInfo.RedirectStandardOutput = true;
> 	p.StartInfo.CreateNoWindow = true;
> 			
> 	p.Start();
> 			
> 	while ( (buf1 = p.StandardOutput.ReadLine() ) != null) {
> 		if (buf1 != null) {
> 			System.Console.WriteLine(buf1);
> 			buffer.Text += buf1 + EOF;
> 		}
> 		p.Refresh();
> 	}
> 	p.WaitForExit();
> 
> It doesnt works fine :-( The dialog that contain the textview is
> blocked... and I have to pass the mouse over the textview to refresh
> it... What's wrong ? Shall I use System.Threads ? The Threads in Gtk are
> well-supported?
> 
> Thanks All!
>