cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
WO1
Helper I
Helper I

How to Make Timer End Early if Condition Met

All,

Looking for a way to make a timer fire the "OnTimerEnd" event early. The problem I am trying to solve: I have created a loading screen that pre-loads all data into Collections, and also checks the app version against a remote share point list in order to verify they are running the latest version and forcing them to update if they are not.  Right now this process can take anywhere between 1-3 seconds depending on connectivity from a mobile device. I have 5 second timer that navigates to the home screen upon Timer End.

 

However, this app may be opened many times each day and I'd like to configure it so that instead of having to wait the full 5 seconds, if load finishes after 1 second it goes ahead to the main screen to save my users some time throughout the day and make it more user friendly.

 

I've tried the following:

 

1. I had two timers, one for my full load time and one that checked every 750ms to see if the conditions had been met and if they had to go to the load screen. The "early detection" timer was set to auto pause. However, I ran into an issue where when the condition would be met and the user would navigate to the main screen the timer would continue to run in the background even though auto pause was selected. This meant if a user selected a button from the main screen it  would load that screen and then immediately navigate to the home screen again (each time the timer was firing the OnTimerEnd event).

 

Setting it to auto pause or setting an update context variable and placing that in the "start" field of each timer did not seem to resolve this. (Interesting note, this didn't occur on the web player, only on mobile version).

 

 

Any ideas on how to accomplish what I'm trying to do?

 

 

3 REPLIES 3
GarethPrisk
Resident Rockstar
Resident Rockstar

Instead of depending on a Timer, would you want to consider moving to an explicit loading pattern? Meaning, instead of having an arbitrary loading time, could you check more explicitly that your loading functions have completed, before navigating the user? Ultimately this solves both quick-loading and slow-loading scenarios appropriately for the user, based on their specific scenario.

 

There are a few suggestions

  • Add a loading/progress/blocking mechanism to show the user that things are happening
    • Rotate an Icon, using a Timer to determine the rotation
    • Simple loading animation from loading.io
    • Increment a 'progress bar' using a Collection of items which are loaded
  • Determine the progress of the load
    • If you are running functions in series, then simply Navigate after they are done
    • If you are running functions Concurrently, then track each branch in a Collection
  • Navigate the user
    • Either an explicit Navigation after things are done
    • Select a Button with the Navigation function (or anything else)
    • Trigger a Timer, and Navigate onTimerEnd

I would definitely be interested in that. I was originally doing that in the following method (Without a timer) in OnVisible of Screen.

 

1. Load Collections

2.  Load Version Number

3. Do Comparison of Version Number (local vs retrieved).  Navigate if appropriate, otherwise show error.

 

This worked for the most part, unless the server was not reachable, then it would hang. Maybe I need to force a timeout on my retrieval and set a variable or something if its forced exit?

 

GarethPrisk
Resident Rockstar
Resident Rockstar

Handling the 'hanging' perception, or slowness, for Users is an important consideration. As long as they believe something is happening, and in an appropriate amount of time, then they will happily wait.

 

PowerApps does, unfortunately, give the impression of being frozen when it has a long-running process. Some will cause even an animated GIF to freeze in the app, such as a complicated ForAll statement. My example below shows this when it gets to the point of creating/loading a matrix of records - that ForAll function is relatively intense, and even an animated image locks up.

 

PowerUsers - Loading Animation.gif

Here I combined a loading spinner Image, and a pattern of collecting a 'progress' record in each loop of a ForAll function. The width of a Shape increments as a percentage of ( CountRows / Total ).

 

How are you doing the License retrieval? It may be possible to introduce an error-handling mechanism, but limited connectivity/timeouts are usually not easily handled in an app.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (3,452)