private void Handle(CapturerItem item) { foreach (string url in item.Urls) { this.Add(url); } }
public void Start() { CapturerItem item = new CapturerItem(this.Url); item.PropertyChanged += item_PropertyChanged; this._CapturerLists.Add(item); item.Start(); }
public void Add(string url) { if (this._Queue.SingleOrDefault(item => item.Url == url) == null) { CapturerItem item = new CapturerItem(url); this._Queue.Enqueue(item); this.Dispatch(); } }
private void Dispatch() { while (this._CurrentTaskCount < MAX_TASK && this._Queue.Count > 0) { CapturerItem item = this._Queue.Dequeue(); item.PropertyChanged += item_PropertyChanged; item.Start(); this._CurrentTaskCount++; } }
void item_PropertyChanged(object sender, PropertyChangedEventArgs e) { CapturerItem item = sender as CapturerItem; item.PropertyChanged -= item_PropertyChanged; if (item.Status == ECapturerStatus.Finish) { this.Handle(item); this._CurrentTaskCount--; this.Dispatch(); } else if (item.Status == ECapturerStatus.Error) { this._CurrentTaskCount--; this.Dispatch(); } }