instead of the
System.Threading.Thread.Sleep(100);
call
t.Join();
Once you click the close, if it does not close, break in the the debugger.
Make sure the main thread is at t.Join() and then check the other thread and
see why it is not exiting.
On 6/14/07, Michael Fasolino <[EMAIL PROTECTED]> wrote:
Alright, so after some more debugging, it appears that the problem wasn't
just a Multi-threading one. In my code one of the first things that I did
on the newly spawned thread was to make some calls into the unmanaged
environment. The parameter lists of one of my dllExport/dllImport pairs
were not matching. For some reason the compiler did not catch this, and
when I was running the app without debugging it seemed like it was working
fine. It was only when I ran the debugger that it caused the GetValue
function to return null. The only thing that I can think of is that some
memory necessary to the Models was being overwritten by the bad parameter
list.
So, my initial problem is solved! But, since we are on the subject of
multithreading, I am having a problem that I had not chased down yet. It is
that after the second thread is spawned when I hit the 'X' to close the app
it becomes unresponsive. It seems like the second thread is not getting
cleaned up properly. Here is what I am doing so far.
James, I implemented the code that you suggested like so:
GLib.Thread.Init();
Gdk.Threads.Init();
Application.Init();
Gdk.Threads.Enter();
...
//Some random setup stuff here (models, combo boxes ect). Should I remove
//this code and place it somewhere else?
...
//I have tried spawning this thread several places, this is just the
latest
System.Threading.Thread t = new System.Threading.Thread(new
System.Threading.ThreadStart(RecieveLoop));
t.Start();
try
{
Application.Run();
}
finally
{
Gdk.Threads.Leave();
}
When I try to close the window, the delete event gets fired, and then it
just seems to hang. I am assuming that I need to do something here, but am
not quite sure what it is.
public void on_MainWindow_delete_event(object o, DeleteEventArgs args)
{
//This bool causes the spawned thread to fall out of its infinate loop
CoeTools.KillRecieverThread = true;
System.Threading.Thread.Sleep(100);
Application.Quit();
args.RetVal = true;
}
Thanks for the help!
*"James Talton" <[EMAIL PROTECTED]>*
06/12/2007 02:10 PM
To
"Michael Fasolino" <[EMAIL PROTECTED]> cc
[EMAIL PROTECTED] Subject
Re: [Gtk-sharp-list] Strange Tree Model behavior (Multi-Threading)
I was seeing weird behavior on Windows with GTK and getting random
exceptions. From some other discussions on this mailing list I did the
following:
Glib.Thread.Init();
Gdk.Threads.Init();
Application.Init();
Gdk.Threads.Enter();
try
{
Application.Run();
}
finally
{
Gdk.Threads.Leave();
}
See if that fixes your problem. If it does, please let us know.
If it does not fix your problem, put a breakpoint where you call GetValue,
open up the threads window and make sure your calls are being done on the
main thread.
- James
On 6/12/07, *Michael Fasolino* <[EMAIL PROTECTED]<[EMAIL PROTECTED]>>
wrote:
All,
Upon further exploration this seems to be a Multi-Threading problem as the
GetValue calls are work fine while debugging until I kick off a second
thread. I am still stumped as to why this will not work while I am
debugging and work fine while I am running with without debugging. I have
gone through the multithreading tutorial on the Mono page and it looks like
I am setting everything up the same as suggested.
Does anyone have any ideas?
Thanks in advance.
*Michael Fasolino <[EMAIL PROTECTED] *<[EMAIL PROTECTED]>
*>*
Sent by: [EMAIL PROTECTED]<[EMAIL PROTECTED]>
06/07/2007 02:08 PM
To
[EMAIL PROTECTED] <[EMAIL PROTECTED]> cc
Subject
[Gtk-sharp-list] Strange Tree Model behavior
This seems really weird to me, but if figured that I would throw it out
and see if anyone else had seen anything like it. I am using Visual Studio
2005 for my development environment. When I run my program in debug mode
the <Model>.GetValue calls seems to all return null. I am not sure if the
problem is with the models or with the GetValue function. Is there an easy
way to view a model's contents when debugging without using the GetValue
function?
I am at a loss as to what would be causing this. When I run the program
without debugging everything works fine.
Any help would be appreciated! Thanks!
Michael _______________________________________________
Gtk-sharp-list maillist - [EMAIL PROTECTED]<[email protected]>
*
**http://lists.ximian.com/mailman/listinfo/gtk-sharp-list*<http://lists.ximian.com/mailman/listinfo/gtk-sharp-list>
_______________________________________________
Gtk-sharp-list maillist - [EMAIL PROTECTED]<[email protected]>
*
**http://lists.ximian.com/mailman/listinfo/gtk-sharp-list*<http://lists.ximian.com/mailman/listinfo/gtk-sharp-list>
_______________________________________________
Gtk-sharp-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
_______________________________________________
Gtk-sharp-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list