<br><font size=3 face="Times New Roman">Alright, so after some more debugging,
it appears that the problem wasn’t just a Multi-threading one. &nbsp;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. &nbsp;The parameter
lists of one of my dllExport/dllImport pairs were not matching. &nbsp;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.
&nbsp;The only thing that I can think of is that some memory necessary
to the Models was being overwritten by the bad parameter list. &nbsp;</font>
<br>
<br><font size=3 face="Times New Roman">So, my initial problem is solved!
&nbsp;But, since we are on the subject of multithreading, I am having a
problem that I had not chased down yet. &nbsp;It is that after the second
thread is spawned when I hit the ‘X’ to close the app it becomes unresponsive.
&nbsp;It seems like the second thread is not getting cleaned up properly.
&nbsp;Here is what I am doing so far. </font>
<br>
<br><font size=3 face="Times New Roman">James, I implemented the code that
you suggested like so:</font>
<br>
<br><font size=2 face="Courier New">GLib.</font><font size=2 color=#4181c0 face="Courier New">Thread</font><font size=2 face="Courier New">.Init();</font>
<br><font size=2 face="Courier New">Gdk.</font><font size=2 color=#4181c0 face="Courier New">Threads</font><font size=2 face="Courier New">.Init();</font>
<br><font size=2 color=#4181c0 face="Courier New">Application</font><font size=2 face="Courier New">.Init();</font>
<br>
<br><font size=2 face="Courier New">Gdk.</font><font size=2 color=#4181c0 face="Courier New">Threads</font><font size=2 face="Courier New">.Enter();</font>
<br>
<br><font size=2 face="Courier New">...</font>
<br><font size=2 face="Courier New">//Some random setup stuff here (models,
combo boxes ect). &nbsp;Should I remove //this code and place it somewhere
else?</font>
<br><font size=2 face="Courier New">...</font>
<br>
<br><font size=2 face="Courier New">//I have tried spawning this thread
several places, this is just the latest </font>
<br><font size=2 face="Courier New">System.Threading.</font><font size=2 color=#4181c0 face="Courier New">Thread</font><font size=2 face="Courier New">
t = </font><font size=2 color=blue face="Courier New">new</font><font size=2 face="Courier New">
System.Threading.</font><font size=2 color=#4181c0 face="Courier New">Thread</font><font size=2 face="Courier New">(</font><font size=2 color=blue face="Courier New">new</font><font size=2 face="Courier New">
</font>
<br><font size=2 face="Courier New">System.Threading.</font><font size=2 color=#4181c0 face="Courier New">ThreadStart</font><font size=2 face="Courier New">(RecieveLoop));</font>
<br><font size=2 face="Courier New">t.Start();</font>
<br>
<br><font size=2 color=blue face="Courier New">try</font>
<br><font size=2 face="Courier New">{</font>
<br><font size=2 color=#4181c0 face="Courier New">Application</font><font size=2 face="Courier New">.Run();</font>
<br><font size=2 face="Courier New">}</font>
<br><font size=2 color=blue face="Courier New">finally</font>
<br><font size=2 face="Courier New">{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</font>
<br><font size=2 face="Courier New">Gdk.</font><font size=2 color=#4181c0 face="Courier New">Threads</font><font size=2 face="Courier New">.Leave();</font>
<br><font size=2 face="Courier New">}</font>
<br><font size=3 face="Times New Roman">&nbsp;</font>
<br>
<br><font size=3 face="Times New Roman">When I try to close the window,
the delete event gets fired, and then it just seems to hang. &nbsp;I am
assuming that I need to do something here, but am not quite sure what it
is. &nbsp;</font>
<br>
<br><font size=2 color=blue face="Courier New">public</font><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">void</font><font size=2 face="Courier New">
on_MainWindow_delete_event(</font><font size=2 color=blue face="Courier New">object</font><font size=2 face="Courier New">
o, </font><font size=2 color=#4181c0 face="Courier New">DeleteEventArgs</font><font size=2 face="Courier New">
args)</font>
<br><font size=2 face="Courier New">{</font>
<br><font size=2 face="Courier New">//This bool causes the spawned thread
to fall out of its infinate loop</font>
<br><font size=2 face="Courier New">CoeTools.KillRecieverThread = </font><font size=2 color=blue face="Courier New">true</font><font size=2 face="Courier New">;
&nbsp;</font>
<br>
<br><font size=2 face="Courier New">System.Threading.</font><font size=2 color=#4181c0 face="Courier New">Thread</font><font size=2 face="Courier New">.Sleep(100);</font>
<br><font size=2 color=#4181c0 face="Courier New">Application</font><font size=2 face="Courier New">.Quit();</font>
<br><font size=2 face="Courier New">args.RetVal = </font><font size=2 color=blue face="Courier New">true</font><font size=2 face="Courier New">;</font>
<br><font size=2 face="Courier New">}</font>
<br>
<br>
<br><font size=3 face="Times New Roman">Thanks for the help!</font>
<br>
<br>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>&quot;James Talton&quot;
&lt;talton@gmail.com&gt;</b> </font>
<p><font size=1 face="sans-serif">06/12/2007 02:10 PM</font>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td><font size=1 face="sans-serif">&quot;Michael Fasolino&quot; &lt;Michael_Fasolino@raytheon.com&gt;</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td><font size=1 face="sans-serif">gtk-sharp-list@ximian.com</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td><font size=1 face="sans-serif">Re: [Gtk-sharp-list] Strange Tree Model
behavior (Multi-Threading)</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=3>I was seeing weird behavior on Windows with GTK and getting
random exceptions. &nbsp;From some other discussions on this mailing list
I did the following:<br>
<br>
Glib.Thread.Init();<br>
Gdk.Threads.Init();<br>
Application.Init(); <br>
<br>
Gdk.Threads.Enter();<br>
try<br>
{<br>
 &nbsp; &nbsp;Application.Run();<br>
}<br>
finally<br>
{ <br>
 &nbsp; &nbsp;Gdk.Threads.Leave();<br>
}<br>
<br>
See if that fixes your problem. &nbsp;If it does, please let us know.<br>
<br>
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. <br>
<br>
 - James<br>
<br>
<br>
</font>
<br><font size=3>On 6/12/07, <b>Michael Fasolino</b> &lt;</font><a href=mailto:Michael_Fasolino@raytheon.com><font size=3 color=blue><u>Michael_Fasolino@raytheon.com</u></font></a><font size=3>&gt;
wrote: </font>
<br><font size=3 face="Times New Roman"><br>
All,</font><font size=3> <br>
</font><font size=3 face="Times New Roman"><br>
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. &nbsp;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. &nbsp;I
have gone through the multithreading tutorial on the Mono page and it looks
like I am setting everything up the same as suggested. &nbsp;</font><font size=3>
<br>
</font><font size=3 face="Times New Roman"><br>
Does anyone have any ideas?</font><font size=3> <br>
</font><font size=3 face="Times New Roman"><br>
Thanks in advance.</font><font size=3> <br>
<br>
<br>
<br>
</font>
<table width=100%>
<tr valign=top>
<td width=54%><font size=1 face="sans-serif"><b>Michael Fasolino &lt;</b></font><a href=mailto:Michael_Fasolino@raytheon.com target=_blank><font size=1 color=blue face="sans-serif"><b><u>Michael_Fasolino@raytheon.com
</u></b></font></a><font size=1 face="sans-serif"><b>&gt;</b> <br>
Sent by: </font><a href="mailto:gtk-sharp-list-bounces@lists.ximian.com" target=_blank><font size=1 color=blue face="sans-serif"><u>gtk-sharp-list-bounces@lists.ximian.com</u></font></a><font size=3>
</font>
<p><font size=1 face="sans-serif">06/07/2007 02:08 PM</font><font size=3>
</font>
<td width=45%>
<br>
<table width=100%>
<tr valign=top>
<td width=15%>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td width=84%><a href="mailto:gtk-sharp-list@ximian.com" target=_blank><font size=1 color=blue face="sans-serif"><u>gtk-sharp-list@ximian.com</u></font></a><font size=3>
</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td><font size=1 face="sans-serif">[Gtk-sharp-list] &nbsp;Strange Tree
Model behavior</font></table>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=50%>
<td width=50%></table>
<br></table>
<br><font size=3><br>
<br>
</font><font size=3 face="Times New Roman"><br>
<br>
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. &nbsp;I am using Visual
Studio 2005 for my development environment. &nbsp;When I run my program
in debug mode the &lt;Model&gt;.GetValue calls seems to all return null.
&nbsp;I am not sure if the problem is with the models or with the GetValue
function. &nbsp;Is there an easy way to view a model's contents when debugging
without using the GetValue function? &nbsp; <br>
<br>
I am at a loss as to what would be causing this. &nbsp;When I run the program
without debugging everything works fine. <br>
<br>
Any help would be appreciated! &nbsp;Thanks!</font><font size=3> </font><font size=2 face="sans-serif"><br>
<br>
Michael</font><font size=3> </font><font size=2><tt>_______________________________________________<br>
Gtk-sharp-list maillist &nbsp;- &nbsp;</tt></font><a href="mailto:Gtk-sharp-list@lists.ximian.com" target=_blank><font size=2 color=blue><tt><u>Gtk-sharp-list@lists.ximian.com</u></tt></font></a><font size=2 color=blue><tt><u><br>
</u></tt></font><a href="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list" target=_blank><font size=2 color=blue><tt><u>http://lists.ximian.com/mailman/listinfo/gtk-sharp-list</u></tt></font></a><font size=3><br>
<br>
<br>
_______________________________________________<br>
Gtk-sharp-list maillist &nbsp;- &nbsp;</font><a href="mailto:Gtk-sharp-list@lists.ximian.com"><font size=3 color=blue><u>Gtk-sharp-list@lists.ximian.com</u></font></a><font size=3>
</font><font size=3 color=blue><u><br>
</u></font><a href="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list" target=_blank><font size=3 color=blue><u>http://lists.ximian.com/mailman/listinfo/gtk-sharp-list</u></font></a><font size=3><br>
</font>
<br>
<br>