Skip to content

Commit fe24fe5

Browse files
committed
fix: add set complete pending task
1 parent 87e1c26 commit fe24fe5

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

TelegramDownloader/Models/DownloadModel.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ public class UploadModel
243243
{
244244
public Mutex mutex = new Mutex();
245245
public event EventHandler<UploadEventArgs> EventChanged;
246+
public event EventHandler EventStatechanged;
246247
public string _internalId { get; set; } = Guid.NewGuid().ToString();
247248
public Guid id = Guid.NewGuid();
248249
public string action { get; set; } = "Upload";
@@ -295,6 +296,7 @@ public virtual void ProgressCallback(long transmitted, long totalSize)
295296
{
296297
endnDate = DateTime.Now;
297298
state = StateTask.Completed;
299+
EventStatechanged?.Invoke(this, EventArgs.Empty);
298300
NotificationModel nm = new NotificationModel();
299301
nm.sendEvent(new Notification($"Upload {name} completed", "Upload Completed", NotificationTypes.Success));
300302
}
@@ -329,6 +331,11 @@ public void InvokeEvent(UploadEventArgs uploadEventArgs)
329331
{
330332
EventChanged?.Invoke(this, uploadEventArgs);
331333
}
334+
335+
protected void InvokeStateChanged()
336+
{
337+
EventStatechanged?.Invoke(this, EventArgs.Empty);
338+
}
332339
}
333340

334341
public class SplitModel : UploadModel
@@ -348,6 +355,7 @@ public override void ProgressCallback(long transmitted, long totalSize)
348355
if (transmitted == totalSize)
349356
{
350357
state = StateTask.Completed;
358+
InvokeStateChanged();
351359
NotificationModel nm = new NotificationModel();
352360
nm.sendEvent(new Notification($"Split {name} completed", "Split Completed", NotificationTypes.Success));
353361
}
@@ -376,6 +384,7 @@ public virtual void Finish()
376384
state = StateTask.Completed;
377385
progress = 100;
378386
mutex.ReleaseMutex();
387+
InvokeStateChanged();
379388
base.InvokeEvent(new UploadEventArgs());
380389
}
381390
}

0 commit comments

Comments
 (0)