This commit is contained in:
TD
2025-03-27 17:51:07 +08:00
parent 8d32269ee0
commit 0865af247a
3 changed files with 48 additions and 37 deletions

View File

@ -73,32 +73,48 @@ namespace DHSoftware
public ProductData( string batchNO, uint pieceNumber, int inferenceLeft = -1) : this(pieceNumber)
{
InferenceLeft = inferenceLeft;
_countdownEvent = new CountdownEvent(inferenceLeft);
//_countdownEvent = new CountdownEvent(inferenceLeft);
BatchNO = batchNO;
}
public void InferenceOne()
{
//lock (_inferenceLock)
//{
// Interlocked.Decrement(ref InferenceLeft);
//}
//public void InferenceOne()
//{
// //lock (_inferenceLock)
// //{
// // Interlocked.Decrement(ref InferenceLeft);
// //}
_countdownEvent.Signal();
// _countdownEvent.Signal();
//}
//public bool InferenceFinished()
//{
// //lock (_inferenceLock)
// //{
// // return 0 == InferenceLeft;
// //}
// return _countdownEvent.CurrentCount == 0; // 判断计数器是否为 0
//}
public void InferenceOne()
{
lock (_inferenceLock)
{
Interlocked.Decrement(ref InferenceLeft);
}
}
public bool InferenceFinished()
{
//lock (_inferenceLock)
//{
// return 0 == InferenceLeft;
//}
return _countdownEvent.CurrentCount == 0; // 判断计数器是否为 0
lock (_inferenceLock)
{
return 0 == InferenceLeft;
}
}