Skip to content

Commit 8a7af3a

Browse files
committed
Fix a potential bug in TaskRecycler
1 parent 04559ed commit 8a7af3a

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/UniGetUI.Core.Classes/TaskRecycler.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private static async Task _runTaskAndWait_VOID(Task task, int hash, int cacheTim
121121
await task;
122122

123123
// Schedule the task for removal after the cache time expires
124-
_removeFromCache(hash, cacheTimeSecsSecs);
124+
_removeFromCache_VOID(hash, cacheTimeSecsSecs);
125125
}
126126

127127
/// <summary>
@@ -166,6 +166,14 @@ private static async void _removeFromCache(int hash, int cacheTimeSecsSecs)
166166

167167
_tasks.Remove(hash, out _);
168168
}
169+
170+
private static async void _removeFromCache_VOID(int hash, int cacheTimeSecsSecs)
171+
{
172+
if (cacheTimeSecsSecs > 0)
173+
await Task.Delay(cacheTimeSecsSecs * 1000);
174+
175+
_tasks_VOID.Remove(hash, out _);
176+
}
169177
}
170178

171179
public static class TaskRecyclerTelemetry

0 commit comments

Comments
 (0)