Wpf DispatchHelper打开新窗口

Wpf DispatchHelper打开新窗口,wpf,mvvm,mvvm-light,Wpf,Mvvm,Mvvm Light,我正在使用MVVM Light中的DispatchHelper在执行计算时打开一个新窗口。该窗口包含一个简单的标签和按钮。当我使用Show方法时,窗口将在计算开始时出现,并在计算结束时关闭,但标签和按钮不在窗口中 在计算开始之前,我尝试过使用ShowDialog方法,并在窗口上显示了标签和按钮。但是,在窗口关闭之前,ShowDialog不会返回。因此,窗口将保持打开状态,并且不会执行计算 有人能就如何解决这个问题提供一些建议吗 public RelayCommand ShowPopupContr

我正在使用MVVM Light中的DispatchHelper在执行计算时打开一个新窗口。该窗口包含一个简单的标签和按钮。当我使用Show方法时,窗口将在计算开始时出现,并在计算结束时关闭,但标签和按钮不在窗口中

在计算开始之前,我尝试过使用ShowDialog方法,并在窗口上显示了标签和按钮。但是,在窗口关闭之前,ShowDialog不会返回。因此,窗口将保持打开状态,并且不会执行计算

有人能就如何解决这个问题提供一些建议吗

public RelayCommand ShowPopupControl
{
    get
    {
        return _showPopupControl 
            ?? (_showPopupControl = new RelayCommand(
                () => {                        
                    DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        var ww = new WorkingWindow();
                        ww.ShowDialog();
                        var loop = new LoopData();
                        loop.DoSomeLoops();
                        ww.Close();

                    });                                    
                }));
    }
}

public class LoopData
{     
    public void DoSomeLoops()
    {          
        for (int i = 0; i < 10000; i++)
        {
            System.Diagnostics.Debug.WriteLine(i);
        }

    }
}

<controls:MetroWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Custom="http://metro.mahapps.com/winfx/xaml/controls" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" 
    x:Class="MetroSpinnerPractice.WorkingWindow"
  xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
    Title="WorkingWindow" Height="200" Width="300">
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>  

    <StackPanel HorizontalAlignment="Center" Height="75" Margin="5" Grid.Row="0" VerticalAlignment="Center" Width="275" Orientation="Horizontal">       

        <Label Content="Working...." 
                VerticalAlignment="Center" 
                Margin="60,20,0,20" 
                FontSize="21.333" 
                HorizontalAlignment="Right" 
                Width="120" 
                Height="40"/>
    </StackPanel>

    <Button x:Name="btnCancelWork" Grid.Row="1"
            Content="Cancel" 
            Width="100" 
            Height="20" 
            HorizontalAlignment="Center" 
            VerticalAlignment="Center" 
            Margin="0" 
            ToolTip="cancel current routine"/>

</Grid>
LoopData方法在UI线程上执行,并阻止更新窗口内容。类似于此问题。