This question is very old, but it still gets some views, so I thought about adding some afterthoughts about this problem.
After reading some documentation (that is not very detailed for such a specific case) and doing some experiments I came to the conclusion that Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack(); method should exit (return true) only after DOM update is completely finished.
However it turned out to be pretty hard to use this kind of approach with high precision because in ASP.NET Web Forms and we did not have complete control of the JS that was generated. So if there are multiple requests after one user action because of nested update panels, or there are some delayed updates or some inconsistencies in execution of JavaScript this kind of approach is not 100% stable.
In the end there probably are two possible partial solutions:
- Accept that this kind of approach does not work accurately in 100% of the cases and deal with it higher levels of abstraction.
- Add other layers on top of this function (for better dealing with multiple AJAX requests in a row or delayed requests) and combine it with smaller waiting times.
Either way there seems to be no clear cut answer that works in 100% of the cases with no explicit waiting in the thread.
This question is very specific and probably cannot get any answers that could be accepted in the future, but I think it contains some interesting points, so I will leave the question open here and accept these afterthoughts.