tags:

views:

23

answers:

1

A Page.PreRender event is guaranteed to be fired after Page.Load event is fired. But is it guaranteed to be fired after Load event handler returned?

A more general question is if event lifecycle of ASP.Net page guarantees that each event is fired only after previous has returned or events can be fired while previous is still executing?

How does answer change if previous event fires some custom event such as DataBound? Can such event be executed in parallel with another event in page lifecycle?

+1  A: 

Yes, the events run synchronous after each other. The events are handled in a single thread, so there can't be two events for the same page running at the same time (except of course if an event calls "sub-events", but then the code calling the "sub-event" doesn't continue to run until it returns).

Guffa
So `DataBound` event fired during data binding in `Page.Load` event can be run along with `Page.PreRender`?
flashnik
@flashnik: No, if the code in the Load event handler calls an event, the event handler for that will run, then the Load event handler continues to run until it returns. After that the PreRender event can run.
Guffa