First commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace Tesses.YouTubeDownloader2025Companion;
|
||||
|
||||
public interface IEventable {
|
||||
Task EventAsync();
|
||||
}
|
||||
|
||||
public class TaskList : IEventable {
|
||||
ConcurrentQueue<Func<Task>> tasks = new ConcurrentQueue<Func<Task>>();
|
||||
public void Enqueue(Func<Task> task)
|
||||
{
|
||||
tasks.Enqueue(task);
|
||||
|
||||
}
|
||||
|
||||
public async Task EventAsync()
|
||||
{
|
||||
try {
|
||||
if(tasks.TryDequeue(out var res))
|
||||
await res();
|
||||
} catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user