ffmediaelement
ffmediaelement copied to clipboard
Loop exit condition in StepTimer.cs
Issue Title
There is an endless loop in Primitives/StepTimer.cs Presumably, there should be an exit condition in it.
Issue Categories
- [x] Bug
Version Information
- [x] Build From Master branch
Sample Code
This is the code of the ExecuteCallbacks( function that never returns:
private static void ExecuteCallbacks(object state)
{
while (true)
{
TickCount++;
if (TickCount >= 60)
{
Resolution = TimeSpan.FromMilliseconds(Stopwatch.Elapsed.TotalMilliseconds / TickCount);
Stopwatch.Restart();
TickCount = 0;
// Debug.WriteLine($"Timer Resolution is now {Resolution.TotalMilliseconds}");
}
Parallel.ForEach(RegisteredTimers, (t) =>
{
if (t.IsRunningCycle || t.IsDisposing)
return;
t.IsRunningCycle = true;
Task.Run(() =>
{
try
{
t.UserCallback?.Invoke();
}
finally
{
t.IsRunningCycle = false;
}
});
});
while (PendingAddTimers.TryDequeue(out var addTimer))
RegisteredTimers.Add(addTimer);
while (PendingRemoveTimers.TryDequeue(out var remTimer))
RegisteredTimers.Remove(remTimer);
Task.Delay(Constants.DefaultTimingPeriod).Wait();
}
}
I think it is a static Callback method not a bug.
Ok, the problem with this is that there is no way to exit the thread and unload ffme objects when closing video window. This could be ok when this is all that a program does, and closing video means exiting the program.. And what if playing some video file is only one of the functions in software?
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.
Ok, the problem with this is that there is no way to exit the thread and unload ffme objects when closing video window. This could be ok when this is all that a program does, and closing video means exiting the program.. And what if playing some video file is only one of the functions in software?
that's a background thread, so if there is no umanaged object in the queue, i think it should be fine.