2007-04-25 Jonathan Pobst <monkey@jpobst.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / XEventQueue.cs
index b418de66982734786fef5d864a70ad3cda5ca11f..11391af1a7279093caeaea71e177f8d3447a5adb 100644 (file)
@@ -39,7 +39,7 @@ 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;
                private static readonly int InitialLXEventSize = 10;
@@ -51,7 +51,7 @@ namespace System.Windows.Forms {
                        paint = new PaintQueue(InitialPaintSize);
                        timer_list = new ArrayList ();
                        this.thread = thread;
-                       this.quit_posted = false;
+                       this.dispatch_idle = true;
                }
 
                public int Count {
@@ -76,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);
                }
 
@@ -88,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 ();
@@ -98,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 ();
@@ -106,13 +121,12 @@ namespace System.Windows.Forms {
                        return xqueue.Peek();
                }
 
-               public bool PostQuitState {
+               public bool DispatchIdle {
                        get {
-                               return quit_posted;
+                               return dispatch_idle;
                        }
-
                        set {
-                               quit_posted = value;
+                               dispatch_idle = value;
                        }
                }