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

s22157809@tuks.co.za s22157809@tuks.co.za
Mon, 31 Jan 2005 22:00:44 +0200 (SAST)


Hi

As far as I know, it has to do with threads.  More specificly the GUI thread. 
You have one thread that draws the GUI(Application.Run). It looks like that ONLY
that thread can cause updates to any Widget or Window.

So a possible solution might be to get the output from the new process to
trigger an event in your GUI thread, so that the GUI thread updates the textview
widget.  

I might be completely off track, but its what I would do :)

Regards,
Ian Galpin

Quoting Antonio Gutiérrez Mayoral <agutierr@gsyc.escet.urjc.es>:

> 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!
> 
> -- 
> Antonio Gutiérrez Mayoral
> Grupo de Sistemas y Comunicaciones <http://gsyc.info>
> Universidad Rey Juan Carlos <http://www.urjc.es>
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>