Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
How to just redirect another page while uploading large sheet which contains more than 1 lac record in .Net.
During this, upload process is running as well as we can see other pages and do some task on other pages.

What I have tried:

This question was asked in interview.
Posted
Updated 20-Sep-16 1:21am

C#
I think that you're expecting your upload to the server to happen in another thread and it won't because it's performing an actual HTTP request and sending the data to your server. I assume that it is the upload that is taking the time and not the logic within the new thread, the speed of the HTTP request is dependent on the connection speed between the server and the uploading party and the speed at which your server can store the information.

What you're doing in your additional thread is just the final processing of the file that has been sent to the server - moving it somewhere else on the file system and creating a thumbnail of the uploaded image. By the time you hit your new thread creation, the file has already been sent to the server.

If you're not doing this already, I suggest sending the upload request using an AJAX request which will execute asynchronously 'behind the scenes' and won't leave your users looking at a frozen screen whilst a 20 second upload is taking place.

The problem is that Ajax uploads require an iFrame and all sorts of fancy techniques to ensure that it is compatible with all browsers. I wouldn't bother doing this yourself unless you want to, but I use the following plugin for all of the uploads on my site and it works like a charm: http://malsup.com/jquery/form/

The method I use is ajaxSubmit() which submits your form using AJAX along with any <input type="file" /> fields.
 
Share this answer
 
I asked same question with my colleague and he told me that we can handle it with by calling asynchronous method using Delegates. Please find below details for your reference.

A useful feature of delegates is the ability to execute a method asynchronously. That is, through a delegate, you can begin invocation of a method and then return immediately while the delegate executes its method in a separate thread. Your page execution does not need to wait for that method to complete.

For more information please refer below link.
Calling a method in C# asynchronously using delegates[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900