2008-03-06 Jonathan Pobst <monkey@jpobst.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / XEventQueue.cs
index 37645db09a871e855e3daa13ec216a0988ca250e..11391af1a7279093caeaea71e177f8d3447a5adb 100644 (file)
@@ -39,7 +39,6 @@ namespace System.Windows.Forms {
                private PaintQueue      paint;  // Paint-only queue
                internal ArrayList      timer_list;
                private Thread          thread;
-               private bool            quit_posted;
                private bool            dispatch_idle;
 
                private static readonly int InitialXEventSize = 100;
@@ -52,7 +51,6 @@ namespace System.Windows.Forms {
                        paint = new PaintQueue(InitialPaintSize);
                        timer_list = new ArrayList ();
                        this.thread = thread;
-                       this.quit_posted = false;
                        this.dispatch_idle = true;
                }
 
@@ -78,6 +76,11 @@ namespace System.Windows.Forms {
 
                public void Enqueue (XEvent xevent)
                {
+                       if (Thread.CurrentThread != thread) {
+                               Console.WriteLine ("Hwnd.Queue.Enqueue called from a different thread without locking.");
+                               Console.WriteLine (Environment.StackTrace);
+                       }
+
                        xqueue.Enqueue (xevent);
                }
 
@@ -90,6 +93,11 @@ namespace System.Windows.Forms {
 
                public XEvent Dequeue ()
                {
+                       if (Thread.CurrentThread != thread) {
+                               Console.WriteLine ("Hwnd.Queue.Dequeue called from a different thread without locking.");
+                               Console.WriteLine (Environment.StackTrace);
+                       }
+
                        if (xqueue.Count == 0) {
                                lock (lqueue) {
                                        return lqueue.Dequeue ();
@@ -100,6 +108,11 @@ namespace System.Windows.Forms {
 
                public XEvent Peek()
                {
+                       if (Thread.CurrentThread != thread) {
+                               Console.WriteLine ("Hwnd.Queue.Peek called from a different thread without locking.");
+                               Console.WriteLine (Environment.StackTrace);
+                       }
+
                        if (xqueue.Count == 0) {
                                lock (lqueue) {
                                        return lqueue.Peek ();
@@ -117,16 +130,6 @@ namespace System.Windows.Forms {
                        }
                }
 
-               public bool PostQuitState {
-                       get {
-                               return quit_posted;
-                       }
-
-                       set {
-                               quit_posted = value;
-                       }
-               }
-
                public class PaintQueue {
 
                        private ArrayList       hwnds;