// public void onContinue(object sender, DownloadProgressChangedEventArgs e) { this.downloadStatus = "Continue"; // if (e.ProgressPercentage > 0) { TimeSpan tss = DateTime.Now - start; long percent = e.ProgressPercentage; long remaining = ((e.TotalBytesToReceive - e.BytesReceived) * Convert.ToInt32(tss.Milliseconds) / e.BytesReceived); // TODO has problem need to FIX it... string result = "N/A"; Console.WriteLine("Remaining time:" + result); if (this.DownloadObserver != null) { this.uodateStatus("Percent: " + e.ProgressPercentage); DownloadArgument dArgument = new DownloadArgument(e, this); dArgument.RemainingTime = result; DownloadObserver.onContinue(dArgument); } } Console.WriteLine($"Download status: {e.ProgressPercentage}%."); }
// public void onComplete(object sender, AsyncCompletedEventArgs e) { DownloadArgument dArgument = new DownloadArgument(e, this); if (e.Error != null) { if (e.Cancelled) { uodateStatus("Cancelled"); downloadStatus = "Cancelled"; } else { uodateStatus(e.Error.Message); downloadStatus = "Error"; } Console.WriteLine(e.Error.Message); } else { downloadStatus = "Completed"; Console.WriteLine("Completed.."); } if (DownloadObserver != null) { DownloadObserver.onComplete(dArgument); } //DownloadObserver = null; }
// void OnAvailabilityChangeHandler(object sender, NetworkAvailabilityEventArgs e) { if (DownloadObserver != null) { uodateStatus("Network: " + e.IsAvailable.ToString()); DownloadObserver.onMessage(new DownloadArgument(e, this)); } }