示例#1
0
        /// <summary>
        /// Call as the entire body of your WndProc.
        /// </summary>
        /// <param name="m"></param>
        public void SequenceWndProc(ref Message m)
        {
#if TESTMS
            if (m_master.GetType().Name == "AtomicReferenceView" && m_obj == 0)
            {
                PropertyInfo pi = m_master.GetType().GetProperty("ObjectHvo");
                if (pi != null)
                {
                    m_obj = (int)pi.GetValue(m_master, null);
                }
                s_fMatchingHvo = m_obj == 6166;                 // (m_obj == 6166 || m_obj == 6792);
            }
#endif
#if TESTMS
            Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc start: " + m_obj.ToString());
#endif
            CheckDisposed();
#if TESTMS
            //Debug.WriteLineIf(m_matchingHvo, "MessageSequencer.SequenceWndProc Must not be disposed.");
#endif

            if (!MethodNeedsSequencing(ref m))
            {
#if TESTMS
                Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc: MethodNeedsSequencing=false: normal handling of message: " + m.ToString());
#endif
                m_receiver.OriginalWndProc(ref m);
                return;                 // not a message we care about.
            }
            if (m_fReentering)
            {
#if TESTMS
                Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc: m_fReentering==true: cache  message: " + m.ToString());
#endif
                m_messages.Add(m);                 // queue and process at end of outer call
            }
            else
            {
#if TESTMS
                Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc m_fReentering==false");
#endif
                try
                {
#if TESTMS
                    Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc try: reset m_fReentering to true; original value: " + m_fReentering.ToString());
#endif
                    m_fReentering = true;
#if TESTMS
                    //Debug.WriteLineIf(m_matchingHvo, "MessageSequencer.SequenceWndProc try: call m_receiver.OriginalWndProc(ref m)");
                    Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc normal handling of watched message start: " + m.ToString());
#endif
                    m_receiver.OriginalWndProc(ref m);
#if TESTMS
                    //Debug.WriteLineIf(m_matchingHvo, "MessageSequencer.SequenceWndProc try: finished call m_receiver.OriginalWndProc(ref m)");
                    Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc normal handling of watched message end: " + m.ToString());
#endif
                    // At this point, we've finished processing the original message.
                    // If there are pending messages, run them. Note that they, too, may
                    // generate interrupts, so we're still in 'reentrant' mode.
#if TESTMS
                    Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc try: call DoPendingMessages()");
#endif
                    // Need to check, since a non-blocking message handler 'out there'
                    // could have called PauseMessageQueueing(), which will set it to false.
                    DoPendingMessages();
#if TESTMS
                    Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc try: finished call DoPendingMessages()");
#endif
                }
                finally
                {
#if TESTMS
                    Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc finally: reset m_fReentering to false; original value: " + m_fReentering.ToString());
#endif
                    m_fReentering = false;
                }
            }
#if TESTMS
            Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc end: " + m_obj.ToString());
#endif
        }