I am working on an ASP.NET application. One requirement by the users is they are capable of exporting to Excel of some UIs. I have worked on them using the Infragistics library, and I have supplied them with the exports they want.
However, some of the UIs they see are so complex that it takes a great amount of time to be accomplished (for a web application experience). For instance, an export may take a few minutes, like 4-5 minutes.
I was wondering, if there would be a way, in which I could make this task to be done asynchronously, using threads and make it to last shorter.
1
I suspect that if you introduce threading to the export-to-Excel process that you’ll now have two problems on your hands instead of just one.
You need to take a deep look into the export code, and preferably run it through a profiler so you can see where time is being spent. Once you know where the bottlenecks are, you can apply the right technology to resolve the issue.
Throwing threads at an unknown problem has a greater probability of making things (much) worse.
While you are investigating what the root of the issue is, you can consider moving the export-to-Excel process into a background process that can run independently of the user’s session. Moving to a background process won’t fix the wait time or the user’s perceptions of things, but it will at least allow the user to go work on something else while they wait for the export to complete.
As Doc Brown pointed out, using background threads is a fairly common technique to free up the main thread. Using a background thread in this way generally doesn’t introduce the potential pitfalls associated with threading an export process. And you can move the process to the background without introducing much if any at all of the mental overhead that comes from using asynchronous threads.
1