This commit is contained in:
luosheng
2023-07-15 13:26:18 +08:00
parent 469c93dcd0
commit d1240e73fb
2 changed files with 8 additions and 1 deletions

View File

@@ -76,6 +76,7 @@ namespace Modbus.Net
{ {
if (!repeat && messageSendingdef.ReceiveMessage == null) if (!repeat && messageSendingdef.ReceiveMessage == null)
{ {
asyncLock?.Dispose();
return await SendMsgInner(message, true); return await SendMsgInner(message, true);
} }
return messageSendingdef; return messageSendingdef;

View File

@@ -53,8 +53,9 @@ namespace Modbus.Net
/// 发送内部 /// 发送内部
/// </summary> /// </summary>
/// <param name="message">发送的信息</param> /// <param name="message">发送的信息</param>
/// <param name="repeat">是否为重发消息</param>
/// <returns>发送信息的定义</returns> /// <returns>发送信息的定义</returns>
protected async Task<MessageWaitingDef> SendMsgInner(byte[] message) protected async Task<MessageWaitingDef> SendMsgInner(byte[] message, bool repeat = false)
{ {
IDisposable asyncLock = null; IDisposable asyncLock = null;
try try
@@ -77,6 +78,11 @@ namespace Modbus.Net
success = messageSendingdef.ReceiveMutex.WaitOne(TimeoutTime); success = messageSendingdef.ReceiveMutex.WaitOne(TimeoutTime);
if (success) if (success)
{ {
if (!repeat && messageSendingdef.ReceiveMessage == null)
{
asyncLock?.Dispose();
return await SendMsgInner(message, true);
}
return messageSendingdef; return messageSendingdef;
} }
} }