[Gtk-sharp-list] Still can't show config dialog, but can show anything else

Jim Norman jnorman at novell.com
Fri May 11 11:02:22 EDT 2007


Aaron,
 
Here's the code I use to invoke a class and a method on the Main Thread.  Invoking any GTK UI on a background thread sometimes works on Windows, and never on linux.  Hope this helps.
 
-Jim
 
 
    public class RunOnMainThread
    {
        private object methodClass;
        private string methodName;
        private object[] arguments;
 
        public static void Run(object methodClass, string methodName, object[] arguments)
        {
            new RunOnMainThread(methodClass, methodName, arguments);
        }
 
        public RunOnMainThread(object methodClass, string methodName, object[] arguments)
        {
            this.methodClass = methodClass;
            this.methodName = methodName;
            this.arguments = arguments;
            GLib.Idle.Add(new GLib.IdleHandler(Go));
        }
 
        private bool Go()
        {
 
            try
            {
                Type t = methodClass.GetType();                
                t.InvokeMember(this.methodName, BindingFlags.InvokeMethod, null, methodClass, arguments);     
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
 
            return false;
        }

>>> On 5/11/2007 at 4:14 AM, in message <20070511101933.50F073480CE at herald.ximian.com>, Aaron Oxford <aaron at hardwarehookups.com.au> wrote:
Hi everyone, hope you are all well.

I'm still getting that problem where my application freezes when I 
try to show a dialog at startup. I've now verified this behaviour on 
several other physical machines. It's driving me around the twist 
working on this great GUI that most people can't start.

I did get one reply to my test app submission, however unfortunately 
that suggestion didn't help in the long run, only temporarily (thanks 
anyway Eskil). Other than that, I don't even know whether the 
behaviour was replicated by anyone. Hint hint :-( .

I can't for the life of me understand how this can happen. If I can't 
open a dialog from a timer thread well after the window opens, when 
can I open one? At any point from within the program I can call the 
same method and successfully open a dialog box on any machine. The 
'check your config' dialog only works for me and me alone. I can't 
see any difference between the two situations, and only *my* computer 
believes me. :-D

Some invisible line is being crossed, and I really need to know what 
it is. I've gone back to stuffing around with different versions of 
Gtk#, order of operations during startup and so on (cause I just 
couldn't get enough last time). Here's my current order of operations 
for starting Gtk#:

         // Initialise the threads.
                 if (!GLib.Thread.Supported) GLib.Thread.Init();
                 Gdk.Threads.Init();
                 Gdk.Threads.Enter();

                 // Start the 'application'.
                 Application.Init();

                 // Create the window.
                 window = new GtkWindow();

                 // Initialise display contents.
                 window.initialise();

                 // Display the window.
                 window.ShowAll();

                 // Start the timer.
                 GLib.Timeout.Add(100, new 
GLib.TimeoutHandler(window.timerTick));

                 // Start Gdk#.
                 Application.Run();

I've pushed this code as far into my app as it will go, just to be 
sure that EVERYTHING is initialised before the GUI. Regardless, it is 
_after_ all this that the dialog opens and the app freezes. Once 
again, if my configuration file is intact, I can open other dialogs 
without problems during normal operation of the program. All that's 
involved in either case is a one line call to the same method passing 
only a string to display as a message.

I am ready to submit the entire app to anyone who will test it for 
me. I *have* to know what is going on here. I will be (even more) 
astoundingly grateful to anyone who can help me with this.

Thanks,

Aaron.
---------------------------------------------------------------------------------
Aaron Oxford   -   aaron+hardwarehookups .com .au
Director, Innovative Computer Solutions (Aust) Pty. Ltd.
49 Maitland Rd, Mayfield, NSW 2304 Australia
http://www.ic ( http://www.ic/ )-solutions.com.au
Developer, SourceForge project VioLet Composer
http://sourceforge.net/projects/buzz-like 

_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com 
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20070511/bb880bca/attachment.html 


More information about the Gtk-sharp-list mailing list