rendered paste bodyIndex: Application.cs
===================================================================
--- Application.cs (revision 61538)
+++ Application.cs (working copy)
@@ -83,13 +83,15 @@
int loops;
MWFThread thread;
- e = threads.Values.GetEnumerator();
- loops = 0;
+ lock (threads) {
+ e = threads.Values.GetEnumerator();
+ loops = 0;
- while (e.MoveNext()) {
- thread = (MWFThread)e.Current;
- if (thread != null && thread.messageloop_started) {
- loops++;
+ while (e.MoveNext()) {
+ thread = (MWFThread)e.Current;
+ if (thread != null && thread.messageloop_started) {
+ loops++;
+ }
}
}
@@ -132,7 +134,9 @@
Application.ApplicationExit(null, EventArgs.Empty);
}
}
- threads[thread_id] = null;
+ lock (threads) {
+ threads.Remove (thread_id);
+ }
}
#endregion // Methods
}
@@ -493,7 +497,7 @@
// Handle exit, Form might have received WM_CLOSE and set 'closing' in response
if ((context.MainForm != null) && (context.MainForm.closing || (Modal && !context.MainForm.Visible))) {
- if (!Modal) {
+ if (!Modal && MWFThread.LoopCount == 1) {
XplatUI.PostQuitMessage(0);
} else {
break;