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)
{
asyncLock?.Dispose();
return await SendMsgInner(message, true);
}
return messageSendingdef;

View File

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