cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Is OnStart code of first window executed before OnVisible of the same window

Hi,

 I came across following issue. I have a pretty big OnStart section where many global variables are set. When I start using them in OnVisible section I have cases that some of them are not yet set. Are OnStart and On Visible executed in parallel or sequencially. Is there a way to make sure that OnStart is fully executed before OnVisible of first window starts running?

Thanks for help
Marcin Jemiol

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Anonymous
Not applicable

I’ve also used a Timer control to ensure all the steps in the OnStart property have completed before other functions I want to call run.

Generally I set a variable as one of the first steps in the OnStart, something like:
Set( background_timer_v, false );

Then for the final step in the OnStart:
Set( background_timer_v, true )

I generally then avoid putting anything in the OnVisible property for the Home screen at least.

For the “Background_Timer” control in the Start and AutoStart properties I set the values to:
“background_timer_v”

Finally in the OnStart property of the Timer control for the last step:
Set( background_timer_v, false )
to ensure it doesn’t run again.

It might be a bit more tricky if you “do” want that code to run each time the user navigates back to the home page, in which case I wouldn’t reset the status of the background_timer_v back to false, but instead on the:
OnVisible property add:
UpdateContext( { page_visible: true })
OnHidden property add:
UpdateContext( { page_visible: false })

And the on the Start & AutoStart properties of the Background_Timer control insert:
background_timer_v && page_visible_v

Also set the timer Repeat property to false

View solution in original post

2 REPLIES 2
Highlighted
Super User III
Super User III

Hi @dzemiol,

You could use a timer control in the OnVisible property to set a delay for a fixed time or when an event at the end of the functions in the OnStart property fires.  For more information regarding the Timer control see canvas-apps/controls/control-timer

Highlighted
Anonymous
Not applicable

I’ve also used a Timer control to ensure all the steps in the OnStart property have completed before other functions I want to call run.

Generally I set a variable as one of the first steps in the OnStart, something like:
Set( background_timer_v, false );

Then for the final step in the OnStart:
Set( background_timer_v, true )

I generally then avoid putting anything in the OnVisible property for the Home screen at least.

For the “Background_Timer” control in the Start and AutoStart properties I set the values to:
“background_timer_v”

Finally in the OnStart property of the Timer control for the last step:
Set( background_timer_v, false )
to ensure it doesn’t run again.

It might be a bit more tricky if you “do” want that code to run each time the user navigates back to the home page, in which case I wouldn’t reset the status of the background_timer_v back to false, but instead on the:
OnVisible property add:
UpdateContext( { page_visible: true })
OnHidden property add:
UpdateContext( { page_visible: false })

And the on the Start & AutoStart properties of the Background_Timer control insert:
background_timer_v && page_visible_v

Also set the timer Repeat property to false

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,019)