首次提交:添加src文件夹代码

This commit is contained in:
2026-02-27 14:02:43 +08:00
commit d330cfbca7
4184 changed files with 5546478 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Cowain.Bake.Common.Core
{
public class MessageEventWaitHandle<T> : EventWaitHandle
{
private T message;
private readonly object lockEvent = new object();//定义锁
public MessageEventWaitHandle(bool initialState, EventResetMode mode)
: base(initialState, mode)
{
}
public bool Set(T message)
{
//lock (lockEvent)
{
this.message = message;
return base.Set();
}
}
public T GetMessage(int timeOut)
{
//lock (lockEvent)//因为这里锁住了set给不了信号
{
if (!base.WaitOne(timeOut)) //为假超时
{
base.Reset();
return default(T);
}
else
{
base.Reset();
return this.message;
}
}
}
}
}