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
31 lines
1003 B
C#
31 lines
1003 B
C#
using System.Collections.Concurrent;
|
|
using System.Diagnostics;
|
|
using Server.Core;
|
|
using Debug = MrWu.Debug.Debug;
|
|
|
|
namespace Server.Net
|
|
{
|
|
public class ServiceThreadManager : SingleInstance<ServiceThreadManager>
|
|
{
|
|
/// <summary>
|
|
/// 线程管理
|
|
/// </summary>
|
|
public ConcurrentDictionary<AService, int> Threads = new ConcurrentDictionary<AService, int>();
|
|
|
|
public void CheckThread(AService service,int threadId)
|
|
{
|
|
if (Threads.TryGetValue(service,out int _threadId))
|
|
{
|
|
if (_threadId != threadId)
|
|
{
|
|
StackTrace stackTrace = new StackTrace();
|
|
Debug.Error($"线程ID不一致:{_threadId} {threadId} {stackTrace.ToString()}");
|
|
}
|
|
}
|
|
else if (!Threads.TryAdd(service, threadId))
|
|
{
|
|
Debug.Error("未正常添加到线程管理!");
|
|
}
|
|
}
|
|
}
|
|
} |