示例#1
0
        public Global.MsgResult ShowMsgBox(Msg msg, eMsgButton msgButton)
        {
            // Workaround: Wenn MessageBox in OnApplyTemplate aufgerufen wird, dann findet eine Exception statt weil die Nachrichtenverarbeitungsschleife des Dispatchers noch deaktiviert ist
            // Das findet man über den Zugriff auf eine interne Member heraus:
            //System.Reflection.MemberInfo[] infos = typeof(Dispatcher).GetMember("_disableProcessingCount", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
            Type      typeDispatcher          = typeof(Dispatcher);
            FieldInfo fieldInfo               = typeDispatcher.GetField("_disableProcessingCount", BindingFlags.NonPublic | BindingFlags.Instance);
            int       _disableProcessingCount = 0;

            if (fieldInfo != null)
            {
                _disableProcessingCount = (int)fieldInfo.GetValue(this.Dispatcher);
            }
            if (_disableProcessingCount <= 0)
            {
                try
                {
                    return(ShowMsgBoxIntern(msg, msgButton));
                }
                catch (InvalidOperationException /*iopEx*/)
                {
                    ShowMsgBoxDelegate  showDel = ShowMsgBoxIntern;
                    DispatcherOperation op      = Dispatcher.BeginInvoke(showDel, DispatcherPriority.Loaded, msg, msgButton);
                    //op.Wait();
                    //return (Global.MsgResult) op.Result;
                    return(Global.MsgResult.None);
                }
            }
            else
            {
                ShowMsgBoxDelegate  showDel = ShowMsgBoxIntern;
                DispatcherOperation op      = Dispatcher.BeginInvoke(showDel, DispatcherPriority.Loaded, msg, msgButton);
                //op.Wait();
                //return (Global.MsgResult) op.Result;
                return(Global.MsgResult.None);
            }
        }
示例#2
0
        private Global.MsgResult ShowMsgBoxIntern(Msg msg, eMsgButton msgButton)
        {
            VBWindowDialogMsg vbMessagebox = new VBWindowDialogMsg(msg, msgButton, this);

            return(vbMessagebox.ShowMessageBox());
        }