daly update on 20230502 by nitload youmu

This commit is contained in:
YoumuLiu
2024-05-03 00:49:56 +08:00
parent 8149dfacb0
commit 66efce19fc
28 changed files with 236 additions and 222 deletions
+25 -22
View File
@@ -43,7 +43,7 @@ namespace StgSharp
public class TimeSpanProvider
{
private Action<SemaphoreFullException> _frameUpdateMissCallback = null;
private Action _frameUpdateMissCallback = null;
private readonly int _maxSpanCount;
private Action _refreshCallback;
@@ -108,7 +108,7 @@ namespace StgSharp
/// </summary>
public static TimeSourceProviderBase DefaultProvider => StgSharpTime.OnlyInstance;
public Action<SemaphoreFullException> FrameUpdateMissCallback
public Action FrameUpdateMissCallback
{
get => _frameUpdateMissCallback;
set => _frameUpdateMissCallback = value;
@@ -140,30 +140,33 @@ namespace StgSharp
internal bool CheckTime(long microseconds)
{
if (microseconds - _spanBegin > _spanLength)
if (microseconds - _spanBegin < _spanLength)
{
_spanBegin = microseconds;
timeSpanCount++;
try
return true;
}
_spanBegin = microseconds;
timeSpanCount++;
if (_refreshCallback != null)
{
_refreshCallback();
}
if (_refreshSemaphore.CurrentCount == 0)
{
_refreshSemaphore.Release();
}
else
{
if (_frameUpdateMissCallback != null)
{
if (_refreshCallback != null)
{
_refreshCallback();
}
_refreshSemaphore.Release();
}
catch (SemaphoreFullException ex)
{
if (_frameUpdateMissCallback != null)
{
_frameUpdateMissCallback(ex);
}
}
if (timeSpanCount > _maxSpanCount)
{
return false;
_frameUpdateMissCallback();
}
}
if (timeSpanCount > _maxSpanCount)
{
return false;
}
return true;
}