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

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
PCI Perspectives
PCI Perspectives
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V2EX - 技术
V2EX - 技术
Google DeepMind News
Google DeepMind News
量子位
博客园_首页
S
SegmentFault 最新的问题
S
Secure Thoughts
F
Full Disclosure
H
Hacker News: Front Page
博客园 - 三生石上(FineUI控件)
U
Unit 42
H
Heimdal Security Blog
N
News and Events Feed by Topic
A
About on SuperTechFans
C
CERT Recently Published Vulnerability Notes
Cyberwarzone
Cyberwarzone
Help Net Security
Help Net Security
The Hacker News
The Hacker News
L
LINUX DO - 最新话题
Application and Cybersecurity Blog
Application and Cybersecurity Blog
罗磊的独立博客
N
News | PayPal Newsroom
Spread Privacy
Spread Privacy
C
Cisco Blogs
C
CXSECURITY Database RSS Feed - CXSecurity.com
云风的 BLOG
云风的 BLOG
A
Arctic Wolf
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Simon Willison's Weblog
Simon Willison's Weblog
B
Blog
人人都是产品经理
人人都是产品经理
TaoSecurity Blog
TaoSecurity Blog
博客园 - 【当耐特】
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
Hugging Face - Blog
Hugging Face - Blog
I
InfoQ
D
DataBreaches.Net
大猫的无限游戏
大猫的无限游戏
Apple Machine Learning Research
Apple Machine Learning Research
L
LINUX DO - 热门话题
Google Online Security Blog
Google Online Security Blog
V
Visual Studio Blog
V
Vulnerabilities – Threatpost
Know Your Adversary
Know Your Adversary
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
B
Blog RSS Feed

博客园 - Beewolf

MarkdownToMediaWiki AI时代开发的开发流程 Blazor下的serilog Oracle From VS2019 TO VS2022问题处理 PLINQ实现Map/Reduce模式 学习 基于微软的RDP远程桌面共享排错 oracle vs2019 edmx 更改 CentOS 7安装odoo 15 删除ELK的索引 ELK故障处理,不知道成功否 软件开发的SOLID原则 阿里云的远程桌面问题 Zabbix增加邮箱后Server宕处理 201811招投标培训要点 openvas scanner 服务未启动修复 Hacker一月间 U盘安装kali中CDROM问题解决 测量衰老 tensorFlow小结 tensorFlow可以运行的代码
异步编程
Beewolf · 2022-08-05 · via 博客园 - Beewolf

学习了一下:C#多线程编程实战。好书!

网上看了大量的async、await资料,还是不明白,直到看了一位兄弟发的https://www.cnblogs.com/MrHanBlog/p/11848728.html,才有点开阔。

程序员还是得多动手才行。

using System;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
namespace Chapter1.Recipe1
{
	class Program
	{
        private static async Task Test()
        {

            Console.Out.WriteLine(2);
            Task.Run(() =>
            {
                Thread.Sleep(2000);
                Console.WriteLine(20);
            });
            GetV();
            Console.Out.WriteLine(21);
            Console.Out.WriteLine(6);
            Console.Out.WriteLine(22);
        }
        private static async Task GetV()
        {
            Console.Out.WriteLine(3);
            Task.Run(() =>
            {
                Thread.Sleep(1000);
                Console.WriteLine(33);
            });
            await Task.Run(() =>
            {
                Thread.Sleep(10000);
                Console.WriteLine(4);
            });
            Console.Out.WriteLine(5);

        }

        static void Main(string[] args)
        {

            Console.Out.WriteLine(1);
            Test();
            Console.Out.WriteLine(7);
            string str = Console.ReadLine();
        }

    }
}

  输出理解了,就理解含义了。

1
2
3
21
6
22
7
33
20
4
5

很有意思啊,编程。