public async void Start() { DBTaskQueue self = this.Get(); while (true) { if (self.Id == 0) { return; } DBTask task = await self.Get(); try { await task.Run(); task.Dispose(); } catch (Exception e) { Log.Error(e.ToString()); } } }
public void Add(DBTask task) { if (this.tcs != null) { var t = this.tcs; this.tcs = null; t.SetResult(task); return; } this.queue.Enqueue(task); }
public Task <DBTask> Get() { if (this.queue.Count > 0) { DBTask task = this.queue.Dequeue(); return(Task.FromResult(task)); } TaskCompletionSource <DBTask> t = new TaskCompletionSource <DBTask>(); this.tcs = t; return(t.Task); }
public Task <DBTask> Get() { TaskCompletionSource <DBTask> t = new TaskCompletionSource <DBTask>(); if (this.queue.Count > 0) { DBTask task = this.queue.Dequeue(); t.SetResult(task); } else { this.tcs = t; } return(t.Task); }
public async void Start() { while (true) { if (this.Id == 0) { return; } DBTask task = await this.Get(); try { await task.Run(); } catch (Exception e) { Log.Error(e.ToString()); } } }
public override async void Start(DBTaskQueue self) { while (true) { if (self.IsDisposed) { return; } DBTask task = await self.Get(); try { await task.Run(); task.Dispose(); } catch (Exception e) { Log.Error(e.ToString()); } } }