Would changing a session variable (i.e. Session[\"Progress\"]) in code below be safe?
This code is part of code-behind of an ASP.Net page.
When running a loop i
This is NOT thread safe, but the session across different open page is safe to change.
So under certain circumstances if you call it is safe.
If you call it only one time from you page, then is safe across different pages. The reason for that is that the session is fully lock the session from the start of page load up to the end.
Some similar answers to prove that.
Web app blocked while processing another web app on sharing same session
Does ASP.NET Web Forms prevent a double click submission?
Trying to make Web Method Asynchronous
If you call it more than one time from the same page, from different threads, then you need synchronization.