[MonoDevelop] Threading issues

Luciano _ lnc19 at hotmail.com
Mon Feb 26 08:33:37 EST 2007


Hi. I guess you will need to read this:

http://www.mono-project.com/Responsive_Applications

The explanation: (As i understand it): Gtk works on its own thread, and all 
the operation must be called from this thread, all the calls from other 
thread could cause unpredictable behaviors.

The easy approach for your code is to use:

Gtk.Application.Invoke ( delegate
{
   PBStatus.Fraction = 0.20;
});

Only a thought: I guess that you don't need other (second one) thread to 
update your ProgressBar, The progress bar will be updated from the new 
thread . I mean: You have the current thread, and you call the second thread 
to Perform your operations and this thread will update your applications.
If you wish an example, i used in my own app.

Is called from here:
http://gcomandos.svn.sourceforge.net/viewvc/gcomandos/trunk/gComandos/gComandos/ui/windows/FindFiles.cs?revision=81&view=markup

And the object that make the operations is here:
http://gcomandos.svn.sourceforge.net/viewvc/gcomandos/trunk/gComandos/gComandos/fs/Search.cs?revision=64&view=markup



>From: "Neil Munro" <neilmunro at gmail.com>
>To: monodevelop-list at lists.ximian.com
>Subject: [MonoDevelop] Threading issues
>Date: Fri, 23 Feb 2007 22:47:14 +0000
>MIME-Version: 1.0
>Received: from lists.ximian.com ([130.57.169.22]) by 
>bay0-mc2-f18.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2444); Fri, 
>23 Feb 2007 14:47:23 -0800
>Received: from galactus.ximian.com (localhost.localdomain [127.0.0.1])by 
>lists.ximian.com (Postfix) with ESMTP id C937A1CFC53;Fri, 23 Feb 2007 
>19:20:01 -0500 (EST)
>Received: from herald.ximian.com (frontgate.ximian.com [130.57.169.19])by 
>lists.ximian.com (Postfix) with ESMTP id 467A71CFC44for 
><monodevelop-list at lists.ximian.com>;Fri, 23 Feb 2007 19:19:59 -0500 (EST)
>Received: by herald.ximian.com (Postfix, from userid 2601)id 28A8270077; 
>Fri, 23 Feb 2007 17:47:19 -0500 (EST)
>Received: from ug-out-1314.google.com (ug-out-1314.google.com 
>[66.249.92.175])by herald.ximian.com (Postfix) with ESMTP id 2E0B770076for 
><monodevelop-list at lists.ximian.com>;Fri, 23 Feb 2007 17:47:15 -0500 (EST)
>Received: by ug-out-1314.google.com with SMTP id 78so486320ugnfor 
><monodevelop-list at lists.ximian.com>;Fri, 23 Feb 2007 14:47:15 -0800 (PST)
>Received: by 10.78.193.19 with SMTP id q19mr235681huf.1172270834741;Fri, 23 
>Feb 2007 14:47:14 -0800 (PST)
>Received: by 10.78.69.4 with HTTP; Fri, 23 Feb 2007 14:47:14 -0800 (PST)
>X-Message-Info: txF49lGdW41IVhCEpnUhd3eJx96SiuA3MFKQ3hMjHbE=
>X-Original-To: monodevelop-list at lists.ximian.com
>Delivered-To: monodevelop-list at lists.ximian.com
>X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on 
>frontgate.ximian.com
>X-Spam-Level: X-Spam-Status: No, score=0.9 required=5.0 
>tests=HTML_60_70,HTML_MESSAGE,MY_OBFUT,RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS 
>version=3.0.3
>X-BeenThere: monodevelop-list at lists.ximian.com
>X-Mailman-Version: 2.1.8
>Precedence: list
>List-Id: MonoDevelop discussion mailing 
>list<monodevelop-list.lists.ximian.com>
>List-Unsubscribe: 
><http://lists.ximian.com/mailman/listinfo/monodevelop-list>, 
><mailto:monodevelop-list-request at lists.ximian.com?subject=unsubscribe>
>List-Archive: <http://lists.ximian.com/pipermail/monodevelop-list>
>List-Post: <mailto:monodevelop-list at lists.ximian.com>
>List-Help: <mailto:monodevelop-list-request at lists.ximian.com?subject=help>
>List-Subscribe: 
><http://lists.ximian.com/mailman/listinfo/monodevelop-list>,<mailto:monodevelop-list-request at lists.ximian.com?subject=subscribe>
>Errors-To: monodevelop-list-bounces at lists.ximian.com
>Return-Path: monodevelop-list-bounces at lists.ximian.com
>X-OriginalArrivalTime: 23 Feb 2007 22:47:23.0494 (UTC) 
>FILETIME=[95507060:01C7579C]
>
>Hi, I posted here a while back about a progress bar issue I had, to be told
>I needed to learn about threading to make it work, I am learning from Mono:
>Kick start and Mono: A Developers guide and both have a bit about threading
>but I still cannot seem to get it right. It is still regarding how to get a
>progress bar to work but I seem to have trouble with threads any help would
>be appreciated.
>
>This is the code i have written so far
>
>                Thread thread;
>
>                ThreadStart download = new ThreadStart ( vDownload );
>                thread = new Thread ( download );
>                thread.Start ( );
>
>                ThreadStart apb = new ThreadStart ( AdjustProgressBar1 );
>                thread = new Thread ( apb );
>                thread.Start ( );
>
>    protected void AdjustProgressBar1 ( )
>    {
>        PBStatus.Fraction = 0.20;
>    }
>
>protected virtual void vDownload()
>    {
>        try
>        {
>            StreamWriter GenerateScript = new StreamWriter ( "download.sh"
>);
>            GenerateScript.WriteLine ( "#!/bin/bash" );
>            GenerateScript.WriteLine ( "mkdir temp" );
>            GenerateScript.WriteLine ( "cd temp" );
>            GenerateScript.WriteLine ( "wget {0}", ENURL.Text );
>            GenerateScript.Close ( );
>
>            ProcessStartInfo ExeScript = new ProcessStartInfo ( );
>            ExeScript.FileName = "chmod";
>            ExeScript.Arguments = "+x download.sh";
>            Process process = Process.Start ( ExeScript );
>            process.WaitForExit ( );
>            process.Close ( );
>
>            ProcessStartInfo RunScript = new ProcessStartInfo ( );
>            RunScript.FileName = "sh";
>            RunScript.Arguments = "download.sh";
>            Process process2 = Process.Start ( RunScript );
>            process2.WaitForExit ( );
>            process2.Close ( );
>        }
>
>        catch (Exception ex)
>        {
>            ENInfo.Text = ex.Message;
>        }
>
>        /*finally
>        {
>            PBStatus.Fraction = 0.20;
>        }*/
>    }
>
>Neil Munro


>_______________________________________________
>Monodevelop-list mailing list
>Monodevelop-list at lists.ximian.com
>http://lists.ximian.com/mailman/listinfo/monodevelop-list

_________________________________________________________________
Visita MSN Latino Noticias: Todo lo que pasa en el mundo y en tu paín, ¡en 
tu idioma! http://latino.msn.com/noticias/



More information about the Monodevelop-list mailing list