<font face="Courier New" size="2">instead of the<br> System.Threading.</font><font color="#4181c0" face="Courier New" size="2">Thread</font><font face="Courier New" size="2">.Sleep(100);</font>
<br>call<br> t.Join();<br><br>Once you click the close, if it does not close, break in the the debugger.<br>Make sure the main thread is at t.Join() and then check the other thread and see why it is not exiting.<br><br>
<br><div><span class="gmail_quote">On 6/14/07, <b class="gmail_sendername">Michael Fasolino</b> <<a href="mailto:Michael_Fasolino@raytheon.com">Michael_Fasolino@raytheon.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><font face="Times New Roman" size="3">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. </font>
<br>
<br><font face="Times New Roman" size="3">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. </font>
<br>
<br><font face="Times New Roman" size="3">James, I implemented the code that
you suggested like so:</font>
<br>
<br><font face="Courier New" size="2">GLib.</font><font color="#4181c0" face="Courier New" size="2">Thread</font><font face="Courier New" size="2">.Init();</font>
<span class="q"><br><font face="Courier New" size="2">Gdk.</font><font color="#4181c0" face="Courier New" size="2">Threads</font><font face="Courier New" size="2">.Init();</font>
<br><font color="#4181c0" face="Courier New" size="2">Application</font><font face="Courier New" size="2">.Init();</font>
<br>
<br><font face="Courier New" size="2">Gdk.</font><font color="#4181c0" face="Courier New" size="2">Threads</font><font face="Courier New" size="2">.Enter();</font>
<br>
<br></span><font face="Courier New" size="2">...</font>
<br><font face="Courier New" size="2">//Some random setup stuff here (models,
combo boxes ect). Should I remove //this code and place it somewhere
else?</font>
<br><font face="Courier New" size="2">...</font>
<br>
<br><font face="Courier New" size="2">//I have tried spawning this thread
several places, this is just the latest </font>
<br><font face="Courier New" size="2">System.Threading.</font><font color="#4181c0" face="Courier New" size="2">Thread</font><font face="Courier New" size="2">
t = </font><font color="blue" face="Courier New" size="2">new</font><font face="Courier New" size="2">
System.Threading.</font><font color="#4181c0" face="Courier New" size="2">Thread</font><font face="Courier New" size="2">(</font><font color="blue" face="Courier New" size="2">new</font><font face="Courier New" size="2">
</font>
<br><font face="Courier New" size="2">System.Threading.</font><font color="#4181c0" face="Courier New" size="2">ThreadStart</font><font face="Courier New" size="2">(RecieveLoop));</font>
<br><font face="Courier New" size="2">t.Start();</font>
<span class="q"><br>
<br><font color="blue" face="Courier New" size="2">try</font>
<br><font face="Courier New" size="2">{</font>
<br><font color="#4181c0" face="Courier New" size="2">Application</font><font face="Courier New" size="2">.Run();</font>
<br><font face="Courier New" size="2">}</font>
<br><font color="blue" face="Courier New" size="2">finally</font>
<br><font face="Courier New" size="2">{
</font>
<br><font face="Courier New" size="2">Gdk.</font><font color="#4181c0" face="Courier New" size="2">Threads</font><font face="Courier New" size="2">.Leave();</font>
<br><font face="Courier New" size="2">}</font>
<br><font face="Times New Roman" size="3"> </font>
<br>
<br></span><font face="Times New Roman" size="3">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. </font>
<br>
<br><font color="blue" face="Courier New" size="2">public</font><font face="Courier New" size="2">
</font><font color="blue" face="Courier New" size="2">void</font><font face="Courier New" size="2">
on_MainWindow_delete_event(</font><font color="blue" face="Courier New" size="2">object</font><font face="Courier New" size="2">
o, </font><font color="#4181c0" face="Courier New" size="2">DeleteEventArgs</font><font face="Courier New" size="2">
args)</font>
<br><font face="Courier New" size="2">{</font>
<br><font face="Courier New" size="2">//This bool causes the spawned thread
to fall out of its infinate loop</font>
<br><font face="Courier New" size="2">CoeTools.KillRecieverThread = </font><font color="blue" face="Courier New" size="2">true</font><font face="Courier New" size="2">;
</font>
<br>
<br><font face="Courier New" size="2">System.Threading.</font><font color="#4181c0" face="Courier New" size="2">Thread</font><font face="Courier New" size="2">.Sleep(100);</font>
<br><font color="#4181c0" face="Courier New" size="2">Application</font><font face="Courier New" size="2">.Quit();</font>
<br><font face="Courier New" size="2">args.RetVal = </font><font color="blue" face="Courier New" size="2">true</font><font face="Courier New" size="2">;</font>
<br><font face="Courier New" size="2">}</font>
<br>
<br>
<br><font face="Times New Roman" size="3">Thanks for the help!</font>
<br>
<br>
<br>
<br>
<br>
<table width="100%">
<tbody><tr valign="top">
<td width="40%"><font face="sans-serif" size="1"><b>"James Talton"
<<a href="mailto:talton@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">talton@gmail.com</a>></b> </font>
<p><font face="sans-serif" size="1">06/12/2007 02:10 PM</font>
</p></td><td width="59%">
<table width="100%">
<tbody><tr valign="top">
<td>
<div align="right"><font face="sans-serif" size="1">To</font></div>
</td><td><span class="q"><font face="sans-serif" size="1">"Michael Fasolino" <<a href="mailto:Michael_Fasolino@raytheon.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Michael_Fasolino@raytheon.com
</a>></font>
</span></td></tr><tr valign="top">
<td>
<div align="right"><font face="sans-serif" size="1">cc</font></div>
</td><td><span class="q"><font face="sans-serif" size="1"><a href="mailto:gtk-sharp-list@ximian.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">gtk-sharp-list@ximian.com</a></font>
</span></td></tr><tr valign="top">
<td>
<div align="right"><font face="sans-serif" size="1">Subject</font></div>
</td><td><font face="sans-serif" size="1">Re: [Gtk-sharp-list] Strange Tree Model
behavior (Multi-Threading)</font></td></tr></tbody></table>
<br>
<table>
<tbody><tr valign="top">
<td>
<br></td><td><br></td></tr></tbody></table>
<br></td></tr></tbody></table><div><span class="e" id="q_1132c0de571be9a4_9">
<br>
<br>
<br><font size="3">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:<br>
<br>
Glib.Thread.Init();<br>
Gdk.Threads.Init();<br>
Application.Init(); <br>
<br>
Gdk.Threads.Enter();<br>
try<br>
{<br>
Application.Run();<br>
}<br>
finally<br>
{ <br>
Gdk.Threads.Leave();<br>
}<br>
<br>
See if that fixes your problem. 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> <</font><a href="mailto:Michael_Fasolino@raytheon.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"><font color="blue" size="3"><u>Michael_Fasolino@raytheon.com
</u></font></a><font size="3">>
wrote: </font>
<br><font face="Times New Roman" size="3"><br>
All,</font><font size="3"> <br>
</font><font face="Times New Roman" size="3"><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. 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. </font><font size="3">
<br>
</font><font face="Times New Roman" size="3"><br>
Does anyone have any ideas?</font><font size="3"> <br>
</font><font face="Times New Roman" size="3"><br>
Thanks in advance.</font><font size="3"> <br>
<br>
<br>
<br>
</font>
<table width="100%">
<tbody><tr valign="top">
<td width="54%"><font face="sans-serif" size="1"><b>Michael Fasolino <</b></font><a href="mailto:Michael_Fasolino@raytheon.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"><font color="blue" face="sans-serif" size="1">
<b><u>Michael_Fasolino@raytheon.com
</u></b></font></a><font face="sans-serif" size="1"><b>></b> <br>
Sent by: </font><a href="mailto:gtk-sharp-list-bounces@lists.ximian.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"><font color="blue" face="sans-serif" size="1"><u>gtk-sharp-list-bounces@lists.ximian.com
</u></font></a><font size="3">
</font>
<p><font face="sans-serif" size="1">06/07/2007 02:08 PM</font><font size="3">
</font>
</p></td><td width="45%">
<br>
<table width="100%">
<tbody><tr valign="top">
<td width="15%">
<div align="right"><font face="sans-serif" size="1">To</font></div>
</td><td width="84%"><a href="mailto:gtk-sharp-list@ximian.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"><font color="blue" face="sans-serif" size="1"><u>gtk-sharp-list@ximian.com</u></font>
</a><font size="3">
</font>
</td></tr><tr valign="top">
<td>
<div align="right"><font face="sans-serif" size="1">cc</font></div>
</td><td>
<br></td></tr><tr valign="top">
<td>
<div align="right"><font face="sans-serif" size="1">Subject</font></div>
</td><td><font face="sans-serif" size="1">[Gtk-sharp-list] Strange Tree
Model behavior</font></td></tr></tbody></table>
<br>
<br>
<table width="100%">
<tbody><tr valign="top">
<td width="50%">
<br></td><td width="50%"><br></td></tr></tbody></table>
<br></td></tr></tbody></table>
<br><font size="3"><br>
<br>
</font><font face="Times New Roman" size="3"><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. 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? <br>
<br>
I am at a loss as to what would be causing this. When I run the program
without debugging everything works fine. <br>
<br>
Any help would be appreciated! Thanks!</font><font size="3"> </font><font face="sans-serif" size="2"><br>
<br>
Michael</font><font size="3"> </font><font size="2"><tt>_______________________________________________<br>
Gtk-sharp-list maillist - </tt></font><a href="mailto:Gtk-sharp-list@lists.ximian.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"><font color="blue" size="2"><tt><u>Gtk-sharp-list@lists.ximian.com
</u></tt></font></a><font color="blue" size="2"><tt><u><br>
</u></tt></font><a href="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"><font color="blue" size="2"><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 - </font><a href="mailto:Gtk-sharp-list@lists.ximian.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"><font color="blue" size="3"><u>Gtk-sharp-list@lists.ximian.com</u>
</font></a><font size="3">
</font><font color="blue" size="3"><u><br>
</u></font><a href="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"><font color="blue" size="3"><u>http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
</u></font></a><font size="3"><br>
</font>
<br>
<br>
</span></div><br>_______________________________________________<br>Gtk-sharp-list maillist - <a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:Gtk-sharp-list@lists.ximian.com">Gtk-sharp-list@lists.ximian.com
</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list" target="_blank">http://lists.ximian.com/mailman/listinfo/gtk-sharp-list</a><br><br></blockquote>
</div><br>