随笔分类 - C#线程
摘要:Task 类和 Task<TResult> 类提供多种方法,这些方法能够帮助你组合多个任务以实现常见模式,你可以等待多个 Task 和 Task<TResult> 对象在一个方法调用中完成。 Task.WhenAny Task.WhenAny 方法异步等待多个 Task 或 Task<TResult
阅读全文
摘要:class Program { // 使用BeginXXX/EndXXX和IAsyncResult对象的方式被称为异步编程模型(APM模式) delegate string RunOnThreadPool(out int threadId); static void Main(string[] ar
阅读全文
摘要:暂停线程: static void Main(string[] args) { Thread thread = new Thread(Common.PrintNumbersWithDelay); thread.Start(); Common.PrintNumbers(); Console.ReadK
阅读全文
摘要:原子操作类: public abstract class CounterBase { public abstract void Increase(); public abstract void Decrease(); } public class CounterNoInterlocked : Cou
阅读全文