private static IPendingHandler CallPendingBox(Window owner, string message, string caption, bool canCancel)
        {
            return((IPendingHandler)Application.Current.Dispatcher.Invoke(new Func <IPendingHandler>(() =>
            {
                var setting = PendingBoxSettings.Setting;
                var windowStyle = XamlUtil.ToXaml(setting.WindowStyle);
                var cancelButtonStyle = XamlUtil.ToXaml(setting.CancelButtonStyle);
                var contentTemplate = XamlUtil.ToXaml(setting.ContentTemplate);
                var spinnerStyle = XamlUtil.ToXaml(setting.SpinnerStyle);
                var createOnNewThread = setting.CreateOnNewThread;
                var cancelButtonContent = setting.CancelButtonContent;
                var interopOwnersMask = setting.InteropOwnersMask;
                var handler = new PendingHandlerImpl();
                var ownerRect = GetOwnerRect(owner);

                if (createOnNewThread)
                {
                    var autoReset = new AutoResetEvent(false);
                    var thread = new Thread(() =>
                    {
                        var pendingWindow = new PendingBoxWindow(owner, interopOwnersMask, ownerRect, message, caption, canCancel, windowStyle, cancelButtonStyle, spinnerStyle, contentTemplate, cancelButtonContent, handler);
                        pendingWindow.Closed += delegate
                        {
                            pendingWindow.Dispatcher.InvokeShutdown();
                        };
                        pendingWindow.Show();
                        autoReset.Set();
                        Dispatcher.Run();
                    });
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.IsBackground = true;
                    thread.Start();
                    autoReset.WaitOne();
                }
                else
                {
                    var pendingWindow = new PendingBoxWindow(owner, interopOwnersMask, null, message, caption, canCancel, windowStyle, cancelButtonStyle, spinnerStyle, contentTemplate, cancelButtonContent, handler);
                    pendingWindow.Show();
                }

                return handler;
            })));
        }
        private static INoticeHandler Show(string message, string caption, bool canClose, MessageBoxIcon icon, ImageSource imageIcon, int?duration)
        {
            return((INoticeHandler)Application.Current.Dispatcher.Invoke(new Func <INoticeHandler>(() =>
            {
                var setting = NoticeBoxSettings.Setting;
                var animationEase = setting.AnimationEase;
                var animationDuration = setting.AnimationDuration;
                var noticeBoxItemStyle = XamlUtil.ToXaml(setting.NoticeBoxItemStyle);
                var createOnNewThread = setting.CreateOnNewThread;

                if (_noticeWindow == null)
                {
                    if (createOnNewThread)
                    {
                        var autoReset = new AutoResetEvent(false);
                        _thread = new Thread(() =>
                        {
                            _noticeWindow = new NoticeBoxWindow(animationEase, animationDuration);
                            _noticeWindow.Closed += delegate
                            {
                                _noticeWindow.Dispatcher.InvokeShutdown();
                            };
                            _noticeWindow.Show();
                            autoReset.Set();
                            Dispatcher.Run();
                        });
                        _thread.SetApartmentState(ApartmentState.STA);
                        _thread.IsBackground = true;
                        _thread.Start();
                        autoReset.WaitOne();
                    }
                    else
                    {
                        _noticeWindow = new NoticeBoxWindow(animationEase, animationDuration);
                        _noticeWindow.Show();
                    }
                }
                var handler = _noticeWindow.AddItem(message, caption, icon, imageIcon, duration, canClose, animationDuration, noticeBoxItemStyle);
                return handler;
            })));
        }