Fix
This commit is contained in:
@@ -16,7 +16,7 @@ namespace Modbus.Net
|
|||||||
|
|
||||||
private bool _taskCancel = false;
|
private bool _taskCancel = false;
|
||||||
|
|
||||||
private bool _activeSema = false;
|
private bool _activateSema = false;
|
||||||
|
|
||||||
private int _waitingListMaxCount;
|
private int _waitingListMaxCount;
|
||||||
|
|
||||||
@@ -39,17 +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"));
|
||||||
_activeSema = activateSema;
|
_activateSema = activateSema;
|
||||||
|
if (_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)
|
||||||
{
|
{
|
||||||
@@ -112,6 +112,10 @@ namespace Modbus.Net
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void SendStart()
|
public override void SendStart()
|
||||||
{
|
{
|
||||||
|
if (_taskCycleSema == null && _activateSema)
|
||||||
|
{
|
||||||
|
_taskCycleSema = new Semaphore(0, _waitingListMaxCount);
|
||||||
|
}
|
||||||
_taskCancel = false;
|
_taskCancel = false;
|
||||||
base.SendStart();
|
base.SendStart();
|
||||||
}
|
}
|
||||||
@@ -146,6 +150,10 @@ namespace Modbus.Net
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (_taskCancel)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
var success = base.AddMessageToList(def);
|
var success = base.AddMessageToList(def);
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user