当前位置:网站首页>C# Task拓展方法
C# Task拓展方法
2022-07-06 20:23:00 【望天hous】
TASK,英语单词,名词、动词,作名词的意思是“(困难的)任务,工作;(语言教学中的)活动”,作动词的意思是“派给某人(任务);对(手段或能力)要求极高”
如果单独想执行一个任务,忽略错误,此方法比较适合使用。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp5
{
public static class PublicTaskExtensions
{
static readonly Action<Task> IgnoreTaskContinuation = task => _ = task.Exception;
public static void Ignore(this Task task)
{
if (task.IsCompleted)
{
_ = task.Exception;
}
else
{
task.ContinueWith(IgnoreTaskContinuation,
CancellationToken.None,
TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously,
TaskScheduler.Default);
}
}
}
}
边栏推荐
- About Confidence Intervals
- 腾讯云原生数据库TDSQL-C入选信通院《云原生产品目录》
- 注意力机制原理
- [untitled]
- CMB's written test - quantitative relationship
- HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
- Jericho turns on the display icon of the classic Bluetooth hid mobile phone to set the keyboard [chapter]
- Install torch 0.4.1
- Depth analysis of compilation constants, classloader classes, and system class loaders
- leetcode
猜你喜欢

杰理之播内置 flash 提示音控制播放暂停【篇】
![[tools] basic concept of database and MySQL installation](/img/9c/626e42097050517a13a2ce7cdab1bb.jpg)
[tools] basic concept of database and MySQL installation

Ubuntu 20 installation des enregistrements redisjson

Can the applet run in its own app and realize live broadcast and connection?

树莓派设置wifi自动连接

Another million qubits! Israel optical quantum start-up company completed $15million financing

Graphical tools package yolov5 and generate executable files exe

Appx代码签名指南

Do you know the five most prominent advantages of E-bidding?

1200.Minimum Absolute Difference
随机推荐
Lost in the lock world of MySQL
Not All Points Are Equal Learning Highly Efficient Point-based Detectors for 3D LiDAR Point
MOS transistor realizes the automatic switching circuit of main and auxiliary power supply, with "zero" voltage drop and static current of 20ua
ubuntu20安装redisjson记录
「小样本深度学习图像识别」最新2022综述
【基于 RT-Thread Studio的CPK-RA6M4 开发板环境搭建】
opencv环境的搭建,并打开一个本地PC摄像头。
Principle of attention mechanism
About Estimation Statistics
Sub pixel corner detection opencv cornersubpix
体会设计细节
如何自定义Latex停止运行的快捷键
RestClould ETL 社区版六月精选问答
如何替换模型的骨干网络(backbone)
房费制——登录优化
SSL证书错误怎么办?浏览器常见SSL证书报错解决办法
Under the tide of "going from virtual to real", Baidu AI Cloud is born from real
哈夫曼树基本概念
Flutter3.0, the applet is not only run across mobile applications
CVPR 2022 best paper candidate | pip: six inertial sensors realize whole body dynamic capture and force estimation