Task.ContinueWith线程安全吗? [英] Is Task.ContinueWith thread safe?

查看:67
本文介绍了Task.ContinueWith线程安全吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个线程使用 ContinueWith()
将动作加入到同一任务中,它是线程安全的吗?还是应该用一些专用的锁将它包装起来?

I have multiple threads that enqueue actions to the same task using ContinueWith() Is it thread safe? Or should I wrap it with some dedicated lock?

推荐答案

这是线程安全的。甚至在任务已完成时也可以使用。

It is thread safe. It even works when the task has already completed.

这篇关于Task.ContinueWith线程安全吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆