简体   繁体   English

C#MVC3 Web应用程序中同时存在不同的线程

[英]Different Thread at same time in C# MVC3 Web Application

I've never really used threading before in C# where I need to have six threads which need to be execute at the same time. 在C#中,我从来没有真正使用过线程,在C#中,我需要有六个线程必须同时执行。 Here is the sample steps 这是示例步骤

1-User will invoke a print request 1-用户将调用打印请求

2- Need to create 5 thread in the background. 2-需要在后台创建5个线程。 This will invoke at the same time and These five thread will create five PDF document. 这将同时调用,这五个线程将创建五个PDF文档。

3- Merge five documents and send response back to the user. 3-合并五个文档,并将响应发送回用户。

Is it possible to handle this by using multi threading in C#. 是否可以通过在C#中使用多线程来处理此问题? If possible how can i hold initial request. 如果可能的话,我怎样才能保留最初的要求。

Additional. 额外。 Is t possible to make number of thread in a dynamic way.(I mean some time 5 thread sometime 6...) 无法以动态方式增加线程数。(我的意思是某个时间5个线程,某个时候6 ...)

Please help me to make a good decision 请帮我做出一个好的决定

Thanks 谢谢

Looking for some thing like this 寻找这样的东西

var task1 = Task.Run(() => Funct1());    
 var task2 = Task.Run(() =>  Funct2());
 var task3 = Task.Run(() => Funct3());    
 var task4 = Task.Run(() =>  Funct4());
 var task5 = Task.Run(() => Funct5());          

    int totalSlept = task1.Result + task2.Result+task3.Result + task4.Result+task5.Result

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM