private void TriggerProgressChanged(long?totalDownloadSize, long totalBytesRead, HttpClient _httpClient)
        {
            if (DownloadProgressChanged == null)
            {
                return;
            }

            double?progressPercentage = null;

            if (totalDownloadSize.HasValue)
            {
                progressPercentage = Math.Round((double)totalBytesRead / totalDownloadSize.Value * 100, 2);
            }

            var e = new DownloadProgressEventArgs()
            {
                TotalFileSize = totalDownloadSize, TotalBytesDownloaded = totalBytesRead, ProgressPercentage = progressPercentage, Filename = _updateInfo.DownloadFileName
            };

            OnDownloadProgressChanged(e);

            if (totalBytesRead == totalDownloadSize)
            {
                Dispose(_httpClient);
            }
        }
Ejemplo n.º 2
0
        public void OnDownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            var args = new DownloadProgressEventArgs()
            {
                TotalFileSize = e.TotalBytesToReceive, TotalBytesDownloaded = e.BytesReceived, ProgressPercentage = e.ProgressPercentage, Filename = _updateInfo.DownloadFileName
            };

            DownloadProgressChanged?.Invoke(this, args);
        }
 protected virtual void OnDownloadProgressChanged(DownloadProgressEventArgs e)
 {
     DownloadProgressChanged?.Invoke(this, e);
 }
Ejemplo n.º 4
0
 private static void DownloadUpdateProgressChanged(object sender, DownloadProgressEventArgs e)
 {
     DownloadProgress?.Invoke(sender, e);
 }