public MainWindow()
        {
            InitializeComponent();

            Thread thread = new Thread(CrossThreadFlush);
            thread.IsBackground = true;
            thread.Start();
        }
        private void CrossThreadFlush()
        {             
                //将sleep和无限循环放在等待异步的外面
                Thread.Sleep(2000);
                Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(ThreadFunction));
          
        }
        private void ThreadFunction()
        {
             userControl11.Visibility = Visibility.Hidden;
        }

//自定义进度代码

 <Grid x:Name="LayoutRoot" Background="Transparent"
              HorizontalAlignment="Center" VerticalAlignment="Center">

        <Grid.RenderTransform>

            <ScaleTransform x:Name="SpinnerScale"
                                ScaleX="1.0" ScaleY="1.0" />

        </Grid.RenderTransform>

        <Canvas RenderTransformOrigin="0.5,0.5"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Width="120" Height="120" >

            <Ellipse Width="20" Height="20"
                         Canvas.Left="24"
                         Canvas.Top="15"
                         Stretch="Fill" Fill="Orange"
                         Opacity="1.0"/>

            <Ellipse Width="20" Height="20"
                         Canvas.Left="12"
                         Canvas.Top="35" Stretch="Fill"
                         Fill="Black" Opacity="0.9"/>

            <Ellipse Width="20" Height="20"
                         Canvas.Left="12"
                         Canvas.Top="59" Stretch="Fill"
                         Fill="Black" Opacity="0.8"/>
            <Ellipse Width="20" Height="20"
                         Canvas.Left="29"
                         Canvas.Top="80" Stretch="Fill"
                         Fill="Black" Opacity="0.6"/>

            <Ellipse Width="20" Height="20"
                         Canvas.Left="55"
                         Canvas.Top="84" Stretch="Fill"
                         Fill="Black" Opacity="0.5"/>

            <Ellipse Width="20" Height="20"
                         Canvas.Left="78"
                         Canvas.Top="72" Stretch="Fill"
                         Fill="Black" Opacity="0.4"/>

            <Ellipse Width="20" Height="20"
                         Canvas.Left="88"
                         Canvas.Top="50" Stretch="Fill"
                         Fill="Black" Opacity="0.3"/>

            <Ellipse Width="20" Height="20"
                         Canvas.Left="83"
                         Canvas.Top="26.9938" Stretch="Fill"
                         Fill="Black" Opacity="0.2"/>

            <Ellipse Width="20" Height="20"
                         Canvas.Left="47.2783"
                         Canvas.Top="7" Stretch="Fill"
                         Fill="Black" Opacity="0.1"/>
          
            <Canvas.RenderTransform>

                <RotateTransform x:Name="SpinnerRotate"
                                     Angle="0" />

            </Canvas.RenderTransform>

            <Canvas.Triggers>

                <EventTrigger RoutedEvent="ContentControl.Loaded">

                    <BeginStoryboard>

                        <Storyboard>

                            <DoubleAnimation
                                    Storyboard.TargetName
                                        ="SpinnerRotate"
                                     Storyboard.TargetProperty
                                        ="(RotateTransform.Angle)"
                                     From="0" To="360"
                                     Duration="0:0:02"
                                     RepeatBehavior="Forever" />

                        </Storyboard>

                    </BeginStoryboard>

                </EventTrigger>

            </Canvas.Triggers>

        </Canvas>
    </Grid>

//CS代码

 public UserControl1()
        {
            InitializeComponent();
            Timeline.DesiredFrameRateProperty.OverrideMetadata(
                      typeof(Timeline),
                          new FrameworkPropertyMetadata { DefaultValue = 40 });
        }