惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

博客园 - 上海-天浩

ASP.NET WebApi(.Net Framework) 应用CacheManager 软件工程的核心问题并非是编程 C# 生产消费模式 C# ConcurrentQueue 处理多任务 最近忙的一个项目(B/S) 共享设备综合运营管理系统(自研) 自动充值机 面向对象的七种设计原则 SQL server 添加主外键约束 做过的项目 诗二首 诗三首 开源大全 C# PowerPoint操作的基本用法。 无锡质检局实验室管理系统 交互式电子白板 自己开发的 漂亮音乐播放器 钥匙齿形识别系统
c# 线程池多任务处理并返回值
上海-天浩 · 2021-03-12 · via 博客园 - 上海-天浩

先新建一个封装类 包含 manual和返回值 

using System;
using System.Threading;
public class ThreadReturnData
{
public ManualResetEvent manual;
public string res;

public void ReturnThreadData(object obj)
{
//操作方法
res = DoSomething(obj);
manual.Set();
}
}

//-------------------------------------------------------------------------------------------------

List<ThreadReturnData> testList = new List<ThreadReturnData>();
IList<ManualResetEvent> arrManual = new List<ManualResetEvent>();
for (int i = 0; i < i; i++)
{
ThreadReturnData temp = new ThreadReturnData();
temp.manual = new ManualResetEvent(false);
arrManual.Add(temp.manual);
ThreadPool.QueueUserWorkItem(new WaitCallback(temp.ReturnThreadData), i);
testList.Add(temp);
}
}
if (arrManual.Count > 0)
{
////等待所有线程执行完
WaitHandle.WaitAll(arrManual.ToArray());
}
foreach (ThreadReturnData d in testList)
{
d.res;
//dowork
}