[MonoDevelop] Process with Mono

Sergey Lobko-Lobanovsky sergey at bitfold.net
Wed Dec 8 04:21:59 EST 2010


One thing I could notice in your code is:

 textview1.Buffer.Text += testo;


I don't have experience in GTK, but in Windows Forms you must modify
controls on the same thread they were created on. If you don't follow this
rule, you are likely to receive intermittent crashes.

On Wed, Dec 8, 2010 at 11:18 AM, Sergey Lobko-Lobanovsky <
serge.lobanovsky at gmail.com> wrote:

> 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
>>
>
>


-- 
Sergey Lobko-Lobanovsky
CEO @ Maygem/Bitfold

Phone: +375 29 6677116
Skype: arilou_camper
Website: www.maygem.net, www.bitfold.net
LinkedIn: www.linkedin.com/in/sergeyl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monodevelop-list/attachments/20101208/da84588f/attachment-0001.html 


More information about the Monodevelop-list mailing list