Ejemplo n.º 1
0
        private void OnSendAndRecv(object sender, RoutedEventArgs e)
        {
            this.Dispatcher.BeginInvoke((System.Action)delegate
            {
                try
                {
                    //发送线程启动处理待发送邮件
                    MailSendWorker.instance.StartTime();

                    if (progressWindow != null && !progressWindow.IsClosed)
                    {
                        progressWindow.IsWinHide = false;
                        progressWindow.Show();
                    }
                    else
                    {
                        MailReceiveWorker worker = new MailReceiveWorker(DateTime.MinValue);

                        progressWindow = new ProgressWindow();
                        progressWindow.IsWinHide = false;
                        progressWindow.Owner = WPFUtil.FindAncestor<Window>(this);
                        progressWindow.worker = worker;
                        worker.Start(progressWindow);
                        progressWindow.Show();
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.Write(ex.StackTrace);
                }
            }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
        }
Ejemplo n.º 2
0
        private void OnAccountManager(object sender, RoutedEventArgs e)
        {
            AccountManagerWindow win = new AccountManagerWindow();
            win.Owner = WPFUtil.FindAncestor<Window>(this);
            if (win.ShowDialog() == true)
            {
                this.Dispatcher.BeginInvoke((System.Action)delegate
                {
                    try
                    {
                        if (progressWindow != null && !progressWindow.IsClosed)
                        {
                            progressWindow.IsWinHide = false;
                            progressWindow.Show();
                        }
                        else
                        {
                            MailReceiveWorker worker = new MailReceiveWorker(DateTime.MinValue, win.InitImportList);

                            progressWindow = new ProgressWindow();
                            progressWindow.Owner = WPFUtil.FindAncestor<Window>(this);
                            progressWindow.worker = worker;
                            worker.Start(progressWindow);
                            progressWindow.Show();
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.Write(ex.StackTrace);
                    }
                }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
            }
        }