Files
hjha-server/ServerCore/CoroutineLock/WaitCoroutineLock.cs
xiaoou e9616125ce feat: initial commit - HJHA game server full source
6 major server modules (PdkFriendServer/GlobalSever/ServerCore/GameModule/GameNetModule) +
game logic (GameFix/GameDAL/ServerData) +
network layer (NetWorkMessage) +
data layer (ObjectModel) +
utilities (MrWu/Core/Config/CloudAPI/dll) +
adapters (zyxAdapter/base)

.NET 8.0 C# solution, 16 projects, 958 source files
2026-07-07 12:02:15 +08:00

51 lines
1.3 KiB
C#

using System;
using System.Threading.Tasks;
namespace Server.Core
{
public class WaitCoroutineLock
{
private TaskCompletionSource<CoroutineLock> tcs;
public static WaitCoroutineLock Create()
{
WaitCoroutineLock waitCoroutineLock = new WaitCoroutineLock();
waitCoroutineLock.tcs = new TaskCompletionSource<CoroutineLock>();
return waitCoroutineLock;
}
public void SetResult(CoroutineLock coroutineLock)
{
if (this.tcs == null)
{
throw new NullReferenceException("SetResult tcs is null");
}
var t = this.tcs;
this.tcs = null;
t.SetResult(coroutineLock);
}
public void SetException(Exception exception)
{
if (this.tcs == null)
{
throw new NullReferenceException("SetException tcs is null");
}
var t = this.tcs;
this.tcs = null;
t.SetException(exception);
}
public bool IsDisposed()
{
return this.tcs == null;
}
public async Task<CoroutineLock> Wait()
{
return await this.tcs.Task;
}
}
}