I am rendering HTML with a foreach loop, like below :
@foreach (var item in list)
{
// some html
}
But it seems that it is iterating the whole loop before starting to render the HTML. I would like to display (render) the html one by one (i.e. if loop iterates 100 times, then it should be render/display the HTML one by one to 100).
Note : To verify that it starts to render the HTML when the loop ends, I did put a thread.sleep(100) inside the loop
@foreach (var item in list)
{
Thread.Sleep(100);
// some html
}
and if it takes 10 mseconds to start rendering the HTML without sleep then after putting thread.sleep it takes 1000 mseconds before starting to render HTML.
Any suggestion as to what I should do so that the UI doesn't get frozen until the loop completes? It should render the HTML as each iteration completes. Thank you.