Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to export csv file in MVC 4 at background process?

I have list of data at UI might be more than 1000 records that i want to export at background level while downloading the file i should be access other actions.
Could you please help me how to maintain the logic for this.

What I have tried:

Jquery is taking so much time and getting the timeout exception
Posted
Updated 18-Nov-18 21:42pm
Comments
F-ES Sitecore 19-Nov-18 5:18am    
You'll probably have to kick the download off in a new tab. If you have a link that does the download, set its target to _blank

<a href="/file/download/123" target="_blank">Download file</a>

1 solution

Hi,

Having a possibility to run different processes at the same time no matter what kind of action they will do needs multithreading. You can use TPL to access great functionalities that Task class provides or use Threads in .Net, both solutions require to separate your downloading process in a different thread than the main thread (for example in WPF there is a GUI thread that in a normal way runs all other actions). So very simple you can try:

Thread in .Net:
C#
var th = new Thread(ExecuteInForeground);
th.Start();
Thread.Sleep(1000);
Console.WriteLine("Main thread ({0}) exiting...",
                      Thread.CurrentThread.ManagedThreadId);
private static void ExecuteInForeground() {//Do something here...}


Task in .Net:
C#
// Create a task and supply a user delegate by using a lambda expression.
Task taskA = new Task( () => Console.WriteLine("Hello from taskA."));
// Start the task.
taskA.Start();


If this did not solve your problem then please leave a comment and I will assist you by improving my solution until your problem gets solved.

Cheers,
AH
 
Share this answer
 
v2
Comments
DGKumar 23-Nov-18 3:01am    
Hi Aydin,
1. Actually i would like to show loading process at the bottom level of browser same like google chrome downloading progress.
But i am not able find out the proper way that i want to do actions while downloading document.
need help on that.

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