如何在后台进程中导出MVC 4中的csv文件? [英] How to export csv file in MVC 4 at background process?

查看:117
本文介绍了如何在后台进程中导出MVC 4中的csv文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

How to export csv file in MVC 4 at background process?



我在UI上有数据列表可能超过1000条记录我想在下载文件时在后台导出我应该访问其他操作。

你能帮我解决一下如何保持逻辑。



我尝试过:



Jquery花了这么多时间并获得超时异常


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

推荐答案





无论他们将采取何种行动,都有可能同时运行不同的流程多线程。您可以使用TPL访问任务类在.Net中提供或使用 Threads 的强大功能,两种解决方案都需要分开您在与主​​线程不同的线程中下载进程(例如在WPF中有一个GUI线程,以正常方式运行所有其他操作)。所以非常简单你可以尝试:



.Net中的线程

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:
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...}





.Net中的任务



Task in .Net:

// 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();





如果这不能解决您的问题,请发表评论,我会帮助您改进我的解决方案,直到您的问题得到解决。



干杯,

AH



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


这篇关于如何在后台进程中导出MVC 4中的csv文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆