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

推荐订阅源

L
LangChain Blog
Engineering at Meta
Engineering at Meta
S
Securelist
M
MIT News - Artificial intelligence
GbyAI
GbyAI
O
OpenAI News
W
WeLiveSecurity
T
Troy Hunt's Blog
L
LINUX DO - 最新话题
博客园_首页
C
Check Point Blog
Martin Fowler
Martin Fowler
The Last Watchdog
The Last Watchdog
量子位
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
SecWiki News
SecWiki News
L
Lohrmann on Cybersecurity
Forbes - Security
Forbes - Security
雷峰网
雷峰网
H
Heimdal Security Blog
P
Palo Alto Networks Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Y
Y Combinator Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
博客园 - 聂微东
Hacker News: Ask HN
Hacker News: Ask HN
Hacker News - Newest:
Hacker News - Newest: "LLM"
Help Net Security
Help Net Security
U
Unit 42
N
News and Events Feed by Topic
Hugging Face - Blog
Hugging Face - Blog
A
About on SuperTechFans
Stack Overflow Blog
Stack Overflow Blog
TaoSecurity Blog
TaoSecurity Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - Franky
Jina AI
Jina AI
美团技术团队
L
LINUX DO - 热门话题
F
Fortinet All Blogs
The GitHub Blog
The GitHub Blog
Security Latest
Security Latest
S
Secure Thoughts
Microsoft Azure Blog
Microsoft Azure Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
IT之家
IT之家
P
Privacy International News Feed
博客园 - 司徒正美

博客园 - 宏宇

C#中多线程Task详解 C#数据去重的5种方式 Automa – AI浏览器扩展工具 超好用的网页端自动化扩展工具-Automa HTTP 请求“报头”——Referer 和 Cookie 使用vs2022将.net8的应用程序发布为一个单独文件 Thread.Abort的.Net Core替代方法 元数据、数据元、数据源、源数据 IIS设置使某IP访问时,跳转到指定页面 IIS自定义错误页面 关闭PerfWatson2.exe 体验改善计划 C# 线程(Thread) 配置 sql server 最大内存 sqlserver内存最佳配置 Windows安装时调出系统的cmd功能 Shift+F10 windows无法安装到这个磁盘,选中的磁盘采用gpt分区 如何删除硬盘efi系统分区 site命令 win10系统图片打开方式为照片查看器的方法 不安装运行时运行.NET程序
C#中一个简单的Task
宏宇 · 2025-06-19 · via 博客园 - 宏宇

简单写一下

    protected void Page_Load(object sender, EventArgs e)
    {
        Run();
    }

    static void Run()
    {
        Task<string> task1 = new Task<string>(() =>
        {
            return Run1("1");
        });
        task1.Start();
        Task<string> task2 = new Task<string>(() =>
        {
            return Run1("2");
        });
        task2.Start();


        Task.WaitAll(task1, task2);

        string s1 = task1.Result;
        string s2 = task2.Result;

    }

    static string Run1(string s)
    {
        Thread.Sleep(20000);
        return s;
    }