Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To Close a Modal Window when thread stops
Message
From
17/04/2010 17:28:57
Antonio Llano
Inmollano S.L.
Getxo, Spain
 
 
To
All
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Title:
How To Close a Modal Window when thread stops
Miscellaneous
Thread ID:
01460765
Message ID:
01460765
Views:
113
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.
Next
Reply
Map
View

Click here to load this message in the networking platform