Fix calling schedule task cause deadlock (#1586)

This commit is contained in:
ReinforceZwei 2021-05-12 22:31:06 +08:00 committed by GitHub
parent 7723ed57ea
commit b15c3a8e46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 6 deletions

View file

@ -67,7 +67,7 @@ namespace MinecraftClient.Protocol.Handlers
PacketTypePalette packetPalette;
SocketWrapper socketWrapper;
DataTypes dataTypes;
Thread netRead;
Thread netRead; // main thread
ILogger log;
public Protocol18Handler(TcpClient Client, int protocolVersion, IMinecraftComHandler handler, ForgeInfo forgeInfo)
@ -1112,6 +1112,15 @@ namespace MinecraftClient.Protocol.Handlers
netRead.Start();
}
/// <summary>
/// Get net read thread (main thread) ID
/// </summary>
/// <returns>Net read thread ID</returns>
public int GetNetReadThreadId()
{
return netRead != null ? netRead.ManagedThreadId : -1;
}
/// <summary>
/// Disconnect from the server, cancel network reading.
/// </summary>