C#多线程编程笔记
文章平均质量分 76
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^
轩阳俊
一位小萌新~
展开
-
C#多线程编程笔记(5.5)-处理异步操作中的异常
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^本篇将描述在C#中使用异步函数时如何处理异常。我们将学习对多个并行的异步操作使用await时如何聚合异常。using System;using System.Threading.Tasks;namespace 处理异步操作中的异常{ class Program { ...原创 2018-07-16 10:52:20 · 3276 阅读 · 0 评论 -
C#多线程编程笔记(5.4)-对并行执行的异步任务使用await操作符
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^本篇将学习如何使用await来并行地运行异步任务,而不是采用常用的顺序执行。using System;using System.Threading.Tasks;using System.Threading;namespace 对并行执行的异步任务使用await操作符{ clas...原创 2018-07-05 14:40:08 · 3691 阅读 · 0 评论 -
C#多线程编程笔记(5.3)-对连续的异步任务使用await操作符
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^本篇将展示当代码中有多个连接的await方法时程序的实际流程是怎样的。我们将学习如何阅读有await方法的代码,以及理解为什么await调用是异步操作。using System;using System.Threading.Tasks;using System.Threading;nam...原创 2018-07-04 16:53:00 · 3688 阅读 · 0 评论 -
C#多线程编程笔记(5.2)-在lambda表达式中使用await操作符
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^using System;using System.Threading.Tasks;using System.Threading;namespace 在Lambda表达式中使用await操作符{ class Program { static void M...原创 2018-07-04 16:09:26 · 4499 阅读 · 0 评论 -
C#多线程编程笔记(5.1)-使用await操作符获取异步任务结果
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^本例将讲述使用异步函数的基本场景,比较使用TPL和使用await操作符获取异步操作结果的不同之处。using System;using System.Threading.Tasks;using System.Threading;using System.Dynamic;using Sys...原创 2018-06-29 10:41:26 · 8010 阅读 · 0 评论 -
C#多线程编程笔记(4.5)-并行运行任务(Task)
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^ using System;using System.Collections.Generic;using System.Threading.Tasks;using System.Threading;namespace 并行运行任务{ class Program { ...原创 2018-06-29 10:24:01 · 10318 阅读 · 0 评论 -
C#多线程编程笔记(4.4)-处理Task任务中的异常
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^原创 2018-06-27 15:25:05 · 10337 阅读 · 1 评论 -
C#多线程编程笔记(4.3)-Task任务中实现取消选项
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^ using System;using System.Threading.Tasks;using System.Threading;namespace 实现取消选项{ class Program { static void Main(string[] ...原创 2018-06-27 15:14:56 · 13250 阅读 · 0 评论 -
C#多线程编程笔记(4.2)-组合任务(Task)
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^ 本节将展示如何设置相互依赖的任务。我们将学习如何创建一个任务,使其在父任务完成后才会被运行。using System;using System.Threading.Tasks;using System.Threading;namespace 组合任务{ class Progr...原创 2018-06-26 10:34:46 · 9781 阅读 · 0 评论 -
C#多线程编程笔记(4.1)-使用Task任务
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^任务(Task)是什么?首先我们先了解一个概念, .Net Framework4.0引入了一个新的关于异步操作的API,叫任务并行库(Task Parallel Library,简称TPL),在.Net Framework4.5版,对该API进行了轻微的改进,使用更简单。TPL可被认为是线程池之...原创 2018-06-26 09:51:12 · 9602 阅读 · 0 评论 -
C#多线程编程笔记(3.5)-使用BackgroundWorker组件
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^本实例演示了另一种异步编程的方式,即使用BackgroundWorker组件。借助于该对象,可以将异步代码组织为一系列事件及事件处理器using System;using System.Threading;using System.ComponentModel;namespace 使用B...原创 2018-06-23 09:30:21 · 12447 阅读 · 0 评论 -
C#多线程编程笔记(3.4)-使用Timer计时器
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^using System;using System.Threading;namespace 使用计时器{ class Program { static void Main(string[] args) { Conso...原创 2018-06-23 09:14:00 · 12734 阅读 · 0 评论 -
C#多线程编程笔记(3.3)-在线程池中使用等待事件处理器及超时
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^using System;using System.Threading;namespace 在线程池中使用等待事件处理器及超时{ class Program { static void Main(string[] args) { ...原创 2018-06-23 09:04:21 · 12976 阅读 · 0 评论 -
C#多线程编程笔记(3.2)-CancellationToken取消异步操作
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^using System;using System.Threading;namespace 线程池中取消异步操作{ class Program { static void Main(string[] args) { using(var...原创 2018-06-15 10:06:28 · 21537 阅读 · 0 评论 -
C#多线程编程笔记(3.1)-线程池ThreadPool与并行度
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^using System;using System.Threading;using System.Diagnostics;namespace 线程池与并行度{ class Program { static void Main(string[] args)...原创 2018-06-15 10:29:51 · 14583 阅读 · 0 评论 -
C#多线程编程笔记(2.8)-使用SpinWait类
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^using System;using System.Threading;namespace SpinWait_Test{ class Program { static void Main(string[] args) { ...原创 2018-06-20 17:02:31 · 16166 阅读 · 0 评论 -
C#多线程编程笔记(2.7)-使用ReaderWriterLockSlim类
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^using System;using System.Collections.Generic;using System.Threading;namespace ReaderWriterLockSlim_Test{ class Program { stati...原创 2018-06-20 16:45:14 · 14452 阅读 · 0 评论 -
C#多线程编程笔记(2.6)-使用Barrier类
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^using System;using System.Threading;namespace Barrier_Test{ class Program { static void Main(string[] args) { ...原创 2018-06-20 15:02:45 · 14391 阅读 · 0 评论 -
C#多线程编程笔记(2.5)-使用CountDownEvent类
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^using System;using System.Threading;namespace CountDownEvent_Test{ class Program { static void Main(string[] args) { ...原创 2018-06-19 15:24:57 · 14684 阅读 · 0 评论 -
C#多线程编程笔记(2.4)-使用ManualResetEventSlim类
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^using System;using System.Threading;namespace ManualResetEventSlim_Test{ class Program { static void Main(string[] args) ...原创 2018-06-19 15:01:00 · 18323 阅读 · 0 评论 -
C#多线程编程笔记(2.3)-使用AuotResetEvent类
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^AuotResetEvent类可以通知等待的线程有某件事发生~using System;using System.Threading;namespace AuotResetEvent_Test{ class Program { static void Ma...原创 2018-06-19 14:42:33 · 14244 阅读 · 0 评论 -
C#多线程编程笔记(2.2)-使用SemaphoreSlim类
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^SemaphoreSlim是Semaphore的轻量级版本,该类限制了同时访问同一个资源的线程数量using System;using System.Threading;namespace semaphoreSlim_Test{ class Program { ...原创 2018-06-19 11:18:18 · 15176 阅读 · 0 评论 -
C#多线程编程笔记(2.1)-使用Mutex类
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^Mutex是一种原始的同步方法,其只对一个线程授予对共享资源的独占访问using System;using System.Threading;namespace MutexTest{ class Program { static void Main(str...原创 2018-06-19 10:25:35 · 14231 阅读 · 0 评论 -
C#多线程编程笔记(1.4)-对Exception的异常处理
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^using System;using System.Threading;namespace 异常处理{ class Program { static void Main(string[] args) { var t ...原创 2018-06-19 09:49:09 · 14316 阅读 · 0 评论 -
C#多线程编程笔记(1.3)-死锁(Dead Lock)解决方法
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^using System;using System.Threading;namespace 死锁{ class Program { static void Main(string[] args) { object l...原创 2018-06-15 14:22:04 · 16473 阅读 · 0 评论 -
C#多线程编程笔记(1.2)-检测线程状态State
近来在学习Eugene Agafonov编写的《C#多线程编程实战》(译),做些笔记也顺便分享一下^-^using System;using System.Threading;namespace 检测线程状态{ class Program { static void Main(string[] args) { Cons...原创 2018-06-15 11:12:43 · 16994 阅读 · 0 评论