[MonoDevelop] Process with Mono

Sergey Lobko-Lobanovsky serge.lobanovsky at gmail.com
Wed Dec 8 04:18:58 EST 2010


How exactly does it crash? What is the generated exception & the stacktrace?

On Wed, Dec 8, 2010 at 2:58 AM, guybrush.d <thera at interfree.it> wrote:

>
> Ciao.
> ok guys i made a step forward (finally!) i'm able to redirect the standard
> output to the textview
> widget of my app using two threads, after launching the command (through
> the
> process method)
> my textview begins to fill with the output, but after some lines (the
> number
> is different each time),
> the program crashes! Here is the code i'm using:
>
> ....
> public frmAvviaInstallazione() :
>        base(Gtk.WindowType.Toplevel)
> {
>                this.Build();
>
>                this.DeleteEvent += delete_event;
>
>
>                Thread thr = new Thread (new ThreadStart (ThreadRoutine));
>                thr.Start ();
>                Thread.Sleep (100);
>
>                Thread thr1 = new Thread (new ThreadStart (LeggiOutput));
>                thr1.Start ();
>
>                if (sortProcess.HasExited)
>                {
>                     thr.Abort();
>                     thr1.Abort();
>                     sortProcess.Close();
>                }
> }
>
> .....
> ....
> public void ThreadRoutine ()
> {
>        AsyncProcess ();
>
> }
>
> public void AsyncProcess()
> {
>        sortProcess.StartInfo.FileName = @"/usr/sbin/slapt-get"; //command
>        sortProcess.StartInfo.Arguments = " --list";    //no need of root
> privileges
>
>        // Set UseShellExecute to false for redirection.
>         sortProcess.StartInfo.UseShellExecute = false;
>        sortProcess.StartInfo.RedirectStandardOutput = true;
>
>         sortProcess.StartInfo.CreateNoWindow = true;
>
>         // Start the process.
>         sortProcess.Start();
>         sortProcess.WaitForExit();
>
> }
>
> void LeggiOutput()
> {
>        while (!sortProcess.HasExited)
>        {
>                string testo = sortProcess.StandardOutput.ReadLine() +
> Environment.NewLine;
>                textview1.Buffer.Text += testo;
>
>                Thread.Sleep (100);
>
>        }
>
> }
>
> Any help is VERY welcome,, thanks in advance, ciao.
> --
> View this message in context:
> http://mono.1490590.n4.nabble.com/Process-with-Mono-tp3042268p3077519.html
> Sent from the Mono - MonoDevelop IDE mailing list archive at Nabble.com.
> _______________________________________________
> Monodevelop-list mailing list
> Monodevelop-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monodevelop-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monodevelop-list/attachments/20101208/519a443b/attachment-0001.html 


More information about the Monodevelop-list mailing list