随笔分类 -  C#线程

摘要:Task 类和 Task<TResult> 类提供多种方法,这些方法能够帮助你组合多个任务以实现常见模式,你可以等待多个 Task 和 Task<TResult> 对象在一个方法调用中完成。 Task.WhenAny Task.WhenAny 方法异步等待多个 Task 或 Task<TResult 阅读全文
posted @ 2021-04-02 13:26 石shi 阅读(176) 评论(0) 推荐(0) 编辑
摘要:class Program { // 使用BeginXXX/EndXXX和IAsyncResult对象的方式被称为异步编程模型(APM模式) delegate string RunOnThreadPool(out int threadId); static void Main(string[] ar 阅读全文
posted @ 2020-05-30 16:50 石shi 阅读(404) 评论(0) 推荐(0) 编辑
摘要:暂停线程: static void Main(string[] args) { Thread thread = new Thread(Common.PrintNumbersWithDelay); thread.Start(); Common.PrintNumbers(); Console.ReadK 阅读全文
posted @ 2020-05-30 14:56 石shi 阅读(289) 评论(0) 推荐(0) 编辑
摘要:原子操作类: public abstract class CounterBase { public abstract void Increase(); public abstract void Decrease(); } public class CounterNoInterlocked : Cou 阅读全文
posted @ 2020-05-30 14:41 石shi 阅读(306) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示