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

推荐订阅源

S
SegmentFault 最新的问题
V
Visual Studio Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
量子位
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
GbyAI
GbyAI
爱范儿
爱范儿
Y
Y Combinator Blog
宝玉的分享
宝玉的分享
有赞技术团队
有赞技术团队
罗磊的独立博客
Recent Announcements
Recent Announcements
博客园 - 司徒正美
M
MIT News - Artificial intelligence
小众软件
小众软件
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
B
Blog RSS Feed
A
About on SuperTechFans
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
雷峰网
雷峰网

博客园 - ®Geovin Du Dream Park™

go: Functional Options Pattern go:Timing Functions Pattern python: Timing Functions Pattern go: Steady-State Pattern python: Steady-State Pattern go: Handshaking Pattern python: Handshaking Pattern go: Fail-Fast Pattern python: Fail-Fast Pattern I go: Deadline Pattern python: Deadline Pattern go: Circuit-Breaker Pattern python: Circuit-Breaker Pattern go: Bulkheads Pattern python: Bulkheads Pattern go: Push & Pull Pattern python: Push & Pull Pattern python: Publish/Subscribe Pattern II go: Publish/Subscribe Pattern python: Publish/Subscribe Pattern go: Futures & Promises Pattern python: Futures & Promises Pattern go: Worker Pool Pattern go:Pipeline Pattern python: Worker Pool Pattern python: Pipeline Pattern go: Fan-Out Pattern python: Fan-Out Pattern go: Fan-In Pattern python: Fan-In Pattern Fan-In
CSharp: Parallel Extensions
®Geovin Du Dream Park™ · 2026-03-29 · via 博客园 - ®Geovin Du Dream Park™
  /// <summary>
    /// Parallel Extensions
    /// </summary>
    class Program
    {
        // 数量配置
        private const int NUM_AES_KEYS = 800000;
        private const int NUM_MD5_HASHES = 100000;

        /// <summary>
        /// 字节数组转16进制字符串
        /// </summary>
        private static string ConvertToHexString(Byte[] byteArray)
        {
            var sb = new StringBuilder(byteArray.Length);
            for (int i = 0; i < byteArray.Length; i++)
            {
                sb.Append(byteArray[i].ToString("X2"));
            }
            return sb.ToString();
        }

        /// <summary>
        /// 生成 AES 密钥(.NET 4.0 必须用 AesManaged)
        /// </summary>
        private static void GenerateAESKeys()
        {
            var sw = Stopwatch.StartNew();

            // .NET 4.0 写法
            using (var aesM = new AesManaged())
            {
                for (int i = 1; i <= NUM_AES_KEYS; i++)
                {
                    aesM.GenerateKey();
                    byte[] result = aesM.Key;
                    string hexString = ConvertToHexString(result);
                }
            }

            // 直接输出到控制台,看得见!
            Console.WriteLine("AES 任务耗时:" + sw.Elapsed);
        }

        /// <summary>
        /// 生成 MD5 哈希
        /// </summary>
        private static void GenerateMD5Hashes()
        {
            var sw = Stopwatch.StartNew();

            using (var md5M = MD5.Create())
            {
                for (int i = 1; i <= NUM_MD5_HASHES; i++)
                {
                    byte[] data = Encoding.Unicode.GetBytes(Environment.UserName + i.ToString());
                    byte[] result = md5M.ComputeHash(data);
                    string hexString = ConvertToHexString(result);
                }
            }

            Console.WriteLine("MD5 任务耗时:" + sw.Elapsed);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            Console.WriteLine("===== .NET 4.0 并行执行演示 =====");
            Console.WriteLine("→ AES 和 MD5 会同时运行,不是先后运行!\n");

            // 开始计时
            var totalSw = Stopwatch.StartNew();

            // ==================== 核心 ====================
            // Parallel.Invoke = 同时执行多个方法(并行)
            // ==============================================
            Parallel.Invoke(
                () => GenerateAESKeys(),   // 任务1
                () => GenerateMD5Hashes()  // 任务2
            );

            totalSw.Stop();

            // 输出总时间
            Console.WriteLine("\n===== 运行完成 =====");
            Console.WriteLine("并行总耗时:" + totalSw.Elapsed);

            Console.WriteLine("\n按回车退出");
            Console.ReadLine();
        }
    }

https://github.com/deepmindd/Cppbooks/blob/main/C%2B%2B%20Concurrency%20in%20Action.pdf
https://github.com/anthonywilliams/ccia_code_samples
https://github.com/xiaoweiChen/Cpp_Concurrency_In_Action
https://github.com/jeremimucha/Cpp-Concurrency-In-Action-2nd-ed
https://github.com/iZhangHui/CCiA
https://github.com/ZouJiu1/multithread_Cplusplus
https://beefnoodles.cc/assets/book/C++%20Concurrency%20in%20Action.pdf
https://www.manning.com/books/concurrency-in-dot-net
https://github.com/subhajitchatterjee07/Concurrency-in-Python
https://github.com/concurrency-in-python-with-asyncio/concurrency-in-python-with-asyncio

https://www.wiley.com/en-us/Essential+Algorithms%3A+A+Practical+Approach+to+Computer+Algorithms+Using+Python+and+C%23%2C+2nd+Edition-p-9781119575993#downloadstab-section
https://ia803202.us.archive.org/31/items/python_ebooks_2020/%5BRod_Stephens%5D_Essential_Algorithms__A_Practical_A.pdf
https://github.com/Belowbelow/ComputerScienceBooks
https://github.com/GrindGold/pdf
https://github.com/SZU-ITer/CS-Books-PDF

https://github.com/jeremiahflaga/concurrency-in-csharp-cookbook-2e
https://www.packtpub.com/en-in/product/hands-on-parallel-programming-with-c-8-and-net-core-3-9781789132410/chapter/introduction-to-parallel-programming-2/section/introduction-to-parallel-programming-ch02lvl1sec02
https://github.com/wagnerhsu/packt-Parallel-Programming-and-Concurrency-with-C-sharp-10-and-.NET-6/
https://github.com/Apress/Parallel-Programming-with-CSharp-and-.NET

哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)