Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have an ASP.NET C# application that needs to go off and iterate through a dire

ID: 650574 • Letter: I

Question

I have an ASP.NET C# application that needs to go off and iterate through a directory of .xml files and do some processing on the data inside them. This is easy enough, but i need to display the result after each .xml is processed, how can this be done?

What im really asking here is how do you process a lot of data in a loop that needs to be displayed back to the client even though the server processing has not fully completed. Is this even possible?

I could start the big process in a seperate thread and start a js timeout to postback and essentially poll the process but this doesn't sound great and would probably require using static variables to maintain state.

Would it be correct to use SessionState / ViewState / QueryString to persist the status of which file ive processed and do away with the loop altogether? Therefore seperate the large job into seperate requests?

Explanation / Answer

The bottom line here is that if you are a server, you can't maintain a persistent connection with your clients. This means that your solution has got to be based on some sort of polling. I would structure it like this:

The caveat to this, naturally, is dependent on how the latency of your client/server connection compares to the average time taken to process each file. Also, do you have to show the user the result of each processing, or is it OK if one is skipped because the processing loop is iterating faster than the display update loop. You could always tie them together, so that the server does not process the next file until it receives a request to do so from the client.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote