Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How To Close a Modal Window when thread stops
Message
De
17/04/2010 17:28:57
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Titre:
How To Close a Modal Window when thread stops
Divers
Thread ID:
01460765
Message ID:
01460765
Vues:
114
Hi,

I have a wpf small window with a tipical "In Progress, please wait..." message and a ProgressBar wich IsIndeterminate property is set to true. When it displays the message appears and the ProgressBar moves.

This window is shown as modal from the main window. When it is showed, as the IsInitialized is set to true, then it starts processing the report in a Thread: The code is
        void ReportWindow_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            ReportWindow window = sender as ReportWindow;
            if (window != null && window.IsVisible == true)
            {
                this.CreateReport();
            }
            else
            {
                this.Close();
            }
        }

        private void CreateReport()
        {
            this.reportThread = new Thread(delegate() { DoReport(MainDataPK); });
            this.reportThread.Start();
         }

        private void DoReport(int tasPK)
        {
            Report report = (new RptValPro()).GetReport(tasPK);

            this.Dispatcher.Invoke(DispatcherPriority.Send, (Action)delegate
            {
                this.EndReport(report);
            });
        }

        private void EndReport(Report report)
        {
            this.ReportDocument = report;            
        }
Then when the Report is created then the EndReport(Report report) method is Invoked and a public Report property is set to the generated report.

From the main window after this modal window is closed then gets the report from the public Report property and then Prints, Shows a preview or exports to PDF or XPS.

So I need the way to Close (Auto Close) the modal window after the Thread is Stopped. Is it possible?

Thanks in advance.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform