可以复制 CRITICAL_SECTION 吗?CRITICAL_SECTION

2023-09-08 09:41:52 作者:逾越旳后果ヽ

可以使用 CRITICAL_SECTION 变量来实现互斥.

One can use a CRITICAL_SECTION variable to get mutual exclusion.

我的问题是:CRITICAL_SECTION 是否支持复制?如果我按值将一个传递给另一个线程,我可以确定互斥会起作用吗?

My question is: does CRITICAL_SECTION support copying? If I pass one by value to another thread, can I know for sure that mutual exclusion will work?

如果答案是你不能那样做",我不会感到惊讶,但最好能得到某种官方确认.无论哪种方式,我都无法在文档中找到声明.

I wouldn't be surprised if the answer is "you cannot do that", but it'd be nice to have some sort of official confirmation. I wasn't able to find a statement either way in the documentation.

推荐答案

没有.CRITICAL_SECTION 无法复制.MSDN 明确声明:

不能移动或复制临界区对象.

A critical section object cannot be moved or copied.

相关推荐