SplashScreen not showing until process ends

3 posts, 0 answers
  1. ANDREI MANU
    ANDREI MANU avatar
    3 posts
    Member since:
    Sep 2018

    Posted 28 Jan Link to this post

         Good day,

     

    Following the instruction in your "Getting Started" section, after just updating the UI for WPF modules, I created a simple MenuItem under my Menu to test it out. 

    The code is rather simple:

    private void Loadingtest(object sender, RoutedEventArgs e)
            {
                var dataContext = (SplashScreenDataContext)RadSplashScreenManager.SplashScreenDataContext;
                dataContext.ImagePath = "";
                dataContext.Content = "Loading";
                dataContext.Footer = "Please wait, this might take several minutes";
                dataContext.MouseCursor = Cursors.Wait;
                dataContext.IsProgressBarVisible = true;
                dataContext.IsIndeterminate = true;
                if (!RadSplashScreenManager.IsSplashScreenActive) {

                    RadSplashScreenManager.Show();
                Thread.Sleep(7000);
                RadSplashScreenManager.Close();
            }

     

    Problem is whenever I click that menuitem it performs the 7 second wait and then flashes the loading screen for a moment before closing it again.

    Tried it as well in WindowLoaded event as well as a Rendered event, both do the same things.

    Tried to do Dispatcher.Invoke, Dispatcher.BeginInvoke as well as a new Tread with a run. All goes the same way. Both in Debug and Release modes. Also, trying to do something like changing the title in between throws an exception about the running thread not being able to access it, as if the whole execution were moved to a new thread after the SplashScreenManager.Show();

     

    Example of the one that causes an error:

     

    private void Loadingtest(object sender, RoutedEventArgs e)
            {
                var dataContext = (SplashScreenDataContext)RadSplashScreenManager.SplashScreenDataContext;
                dataContext.ImagePath = "";
                dataContext.Content = "Loading";
                dataContext.Footer = "Please wait, this might take several minutes";
                dataContext.MouseCursor = Cursors.Wait;
                dataContext.IsProgressBarVisible = true;
                dataContext.IsIndeterminate = true;
                if (!RadSplashScreenManager.IsSplashScreenActive) {
                    RadSplashScreenManager.Show();

                this.Title = "Title Test";
                Thread.Sleep(7000);
                RadSplashScreenManager.Close();
            }

     

    Thanks a bunch!

  2. ANDREI MANU
    ANDREI MANU avatar
    3 posts
    Member since:
    Sep 2018

    Posted 28 Jan in reply to ANDREI MANU Link to this post

    For some reason it won't let me edit the main post; there's also a problem with the timing of it all and the access to IsSplashScreenActive. The following code throws an error that says "InvalidOperationException: You cannot show more than one instance of the splash screen"

     

    if (!RadSplashScreenManager.IsSplashScreenActive)
                    RadSplashScreenManager.Show();
                RadSplashScreenManager.Close();
                var dataContext = (SplashScreenDataContext)RadSplashScreenManager.SplashScreenDataContext;
                dataContext.ImagePath = "";
                dataContext.Content = "Loading";
                dataContext.Footer = "Please wait, this might take several minutes";
                dataContext.MouseCursor = Cursors.Wait;
                dataContext.IsProgressBarVisible = true;
                dataContext.IsIndeterminate = true;
                if (!RadSplashScreenManager.IsSplashScreenActive)
                    RadSplashScreenManager.Show();
                MessageBox.Show("TEST");
                RadSplashScreenManager.Close();

     

    If I remove the one above, it would show "TEST" then show and close the splash screen.

  3. Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    569 posts

    Posted 31 Jan Link to this post

    Hi Andrei,

    Thank you for the provided code snippets. 

    I tested the described scenario on my end, however I was not able to replicate the described behavior. That is why I am attaching the sample project, which I used for testing purposes. Can you check it out and let me know, if I am missing something? 

    I am looking forward to your reply.

    Regards,
    Vladimir Stoyanov
    Progress Telerik

    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top