Beispiel #1
0
        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());
                }
            }
        }
Beispiel #2
0
        public void Add(DBTask task)
        {
            if (this.tcs != null)
            {
                var t = this.tcs;
                this.tcs = null;
                t.SetResult(task);
                return;
            }

            this.queue.Enqueue(task);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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());
                }
            }
        }
Beispiel #6
0
        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());
                }
            }
        }