Windows允许创建(命名)Event objects。 事件(Windows中的同步原语)可以是自动重置类型(在这种情况下,您可以是could say it's kind of a semaphore),也可以是手动重置类型,在这种情况下它将保持设置状态,直到有人重置为止。 现在,从docs为CreateEvent,OpenEvent,SetEvent,等它似乎是没有办法确定,一旦事件已经创建
我正在尝试执行AutoResetEvent。为了这个目的,我使用了一个非常简单的类: public class MyThreadTest
{
static readonly AutoResetEvent thread1Step = new AutoResetEvent(false);
static readonly AutoResetEvent thread2Step = n
从不同线程调用AutoResetEvent方法是否安全? 还是应该避免从不同线程中调用对象? class Test
{
EventWaitHandle wh = new AutoResetEvent(false);
Thread worker = new(Work);
public Test
{
worker.Start();
}
private void WaitForDriveToBecomeReady()
{
AutoResetEvent syncEvent = new AutoResetEvent(false); //set wait signal to use later
//dispatcher to be able to change stuff in xaml from within