Fix
This commit is contained in:
@@ -16,9 +16,11 @@ namespace Modbus.Net
|
|||||||
|
|
||||||
private bool _taskCancel = false;
|
private bool _taskCancel = false;
|
||||||
|
|
||||||
|
private bool _activeSema = false;
|
||||||
|
|
||||||
private int _waitingListMaxCount;
|
private int _waitingListMaxCount;
|
||||||
|
|
||||||
private readonly Semaphore _taskCycleSema;
|
private Semaphore _taskCycleSema;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 间隔时间
|
/// 间隔时间
|
||||||
@@ -37,16 +39,17 @@ namespace Modbus.Net
|
|||||||
: base(lengthCalc, checkRightFunc)
|
: base(lengthCalc, checkRightFunc)
|
||||||
{
|
{
|
||||||
_waitingListMaxCount = int.Parse(waitingListMaxCount != null ? waitingListMaxCount.ToString() : null ?? ConfigurationReader.GetValueDirect("Controller", "WaitingListCount"));
|
_waitingListMaxCount = int.Parse(waitingListMaxCount != null ? waitingListMaxCount.ToString() : null ?? ConfigurationReader.GetValueDirect("Controller", "WaitingListCount"));
|
||||||
if (activateSema)
|
_activeSema = activateSema;
|
||||||
{
|
|
||||||
_taskCycleSema = new Semaphore(0, _waitingListMaxCount);
|
|
||||||
}
|
|
||||||
AcquireTime = acquireTime;
|
AcquireTime = acquireTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void SendingMessageControlInner()
|
protected override void SendingMessageControlInner()
|
||||||
{
|
{
|
||||||
|
if (_activeSema)
|
||||||
|
{
|
||||||
|
_taskCycleSema = new Semaphore(0, _waitingListMaxCount);
|
||||||
|
}
|
||||||
_taskCycleSema?.WaitOne();
|
_taskCycleSema?.WaitOne();
|
||||||
while (!_taskCancel)
|
while (!_taskCancel)
|
||||||
{
|
{
|
||||||
@@ -101,6 +104,9 @@ namespace Modbus.Net
|
|||||||
_taskCycleSema?.WaitOne();
|
_taskCycleSema?.WaitOne();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_taskCycleSema.Dispose();
|
||||||
|
_taskCycleSema = null;
|
||||||
|
Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
Reference in New Issue
Block a user