Пример #1
0
        private void BeginWorking()
        {
            lock (this)
            {
                if (_isWorking)
                {
                    return;
                }

                Status = new AsyncPurgeStatus {
                    IsRunning = true
                };
                _isWorking = true;
                worker.DoWork(() =>
                {
                    Work work;
                    while (workQueue.TryDequeue(out work))
                    {
                        work.Task();
                    }

                    lock (this)
                    {
                        _isWorking = false;
                    }
                });
            }
        }
Пример #2
0
        public virtual void BeginPurge(int rootID)
        {
            workQueue.Enqueue(new Work
            {
                Task = () =>
                {
                    var item = persister.Get(rootID);
                    if (item == null)
                    {
                        return;
                    }

                    string title = item.Title;
                    Status       = new AsyncPurgeStatus {
                        IsRunning = true, Progress = new PurgingStatus {
                            Deleted = 0, Remaining = 1
                        }, Title = title
                    };

                    trash.Purge(item, (s) => { Status = new AsyncPurgeStatus {
                                                   IsRunning = true, Progress = s, Title = title
                                               }; });
                    Status = null;
                }
            });
            BeginWorking();
        }
Пример #3
0
		public virtual void BeginPurgeAll()
		{
			workQueue.Enqueue(new Work { Task = () => 
			{
				Status = new AsyncPurgeStatus { IsRunning = true, Progress = new PurgingStatus { Deleted = 0, Remaining = 1 }, Title = "All" };
				trash.PurgeAll(s => { Status = new AsyncPurgeStatus { IsRunning = true, Progress = s, Title = "All" }; });
				Status = null;
			}});
			BeginWorking();
		}
Пример #4
0
 public virtual void BeginPurgeAll()
 {
     workQueue.Enqueue(new Work {
         Task = () =>
         {
             Status = new AsyncPurgeStatus {
                 IsRunning = true, Progress = new PurgingStatus {
                     Deleted = 0, Remaining = 1
                 }, Title = "All"
             };
             trash.PurgeAll((s) => { Status = new AsyncPurgeStatus {
                                         IsRunning = true, Progress = s, Title = "All"
                                     }; });
             Status = null;
         }
     });
     BeginWorking();
 }
Пример #5
0
		public virtual void BeginPurge(int rootId)
		{
			workQueue.Enqueue(new Work
			{
				Task = () =>
				{
					var item = persister.Get(rootId);
					if (item == null)
						return;

					string title = item.Title;
					Status = new AsyncPurgeStatus { IsRunning = true, Progress = new PurgingStatus { Deleted = 0, Remaining = 1 }, Title = title };

					trash.Purge(item, s => { Status = new AsyncPurgeStatus { IsRunning = true, Progress = s, Title = title }; });
					Status = null;
				}
			});
			BeginWorking();
		}
Пример #6
0
		private void BeginWorking()
		{
			lock (this)
			{
				if (_isWorking)
					return;

				Status = new AsyncPurgeStatus { IsRunning = true };
				_isWorking = true;
				worker.DoWork(() =>
					{
						Work work;
						while (workQueue.TryDequeue(out work))
						{
							work.Task();
						}

						lock (this)
						{
							_isWorking = false;
						}
					});
			}
		}