daly update on 20230502 by nitload youmu
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user