Ask a questionAsk a question
 

AnswerSetting a timer on a window

  • Thursday, February 23, 2006 10:10 AMKimme Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi there,

    is it possible to set a timer on a certain window? I have created an application and I've created a kind of "loader-window" for that application. Can the loader now be shown while the application is being loaded, or will I have to set some sort of timer on the loader? And how?

    greets,

    Kimme

Answers

  • Monday, February 27, 2006 11:29 PMMarjan Badiei - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi Kimme,

     

    Jason Brittsan from MSFT has this sample for you to show a splash screen until the ap is ready. Hope you are set now. 

     

    Marjan 

     

            void WindowLoaded(object sender, RoutedEventArgs args)

            {

                DispatcherTimer dt = new DispatcherTimer(DispatcherPriority.Normal);

                dt.Interval = new TimeSpan(0, 0, 5);

                dt.Tick += new EventHandler(dt_Tick);

     

                dt.Start();

            }

     

            void dt_Tick(object sender, EventArgs e)

            {

                this.Close();

            }

All Replies

  • Thursday, February 23, 2006 4:04 PMMichaelLattaModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    The difficult thing is going to be to open your window before the application is fully loaded.  Since showing the window is going to require the frameworks to be loaded.  If you have significant application level start-up time then you can do this pretty easily.  Create an instance of your spash window and show it.  Then when your startup logic is done close it.  You can use a timer, but that does not seem to match the use case.  You would not want to slow down the start up time to match the timer would you?
  • Thursday, February 23, 2006 4:21 PMKimme Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    If that is the only possibility, so it will be. How can I do that?
  • Monday, February 27, 2006 11:29 PMMarjan Badiei - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi Kimme,

     

    Jason Brittsan from MSFT has this sample for you to show a splash screen until the ap is ready. Hope you are set now. 

     

    Marjan 

     

            void WindowLoaded(object sender, RoutedEventArgs args)

            {

                DispatcherTimer dt = new DispatcherTimer(DispatcherPriority.Normal);

                dt.Interval = new TimeSpan(0, 0, 5);

                dt.Tick += new EventHandler(dt_Tick);

     

                dt.Start();

            }

     

            void dt_Tick(object sender, EventArgs e)

            {

                this.Close();

            }