private void Current_FileUploadProgress(object sender, FileUploadProgress e) { Device.BeginInvokeOnMainThread(() => { ProgressBar.ProgressTo(e.Percentage / 100.0f, 100, Easing.Linear); }); }
private void Current_FileUploadProgress(object sender, FileUploadProgress e) { Device.BeginInvokeOnMainThread(() => { progress.Progress = e.Percentage / 100.0f; }); }
private async void UpdateFileUploadProgressAsync(object sender, FileUploadProgress e) { foreach (var image in _vehicle.Images.Where(vi => vi.Tag == e.Tag)) { await Device.InvokeOnMainThreadAsync(() => image.UploadProgress = e.Percentage / 100.0f); } }
// Note that this event is invoked on a background thread, so we cannot access the UI directly. private void UploadProgress(UploadOperation upload) { // UploadOperation.Progress is updated in real-time while the operation is ongoing. Therefore, // we must make a local copy so that we can have a consistent view of that ever-changing state // throughout this method's lifetime. BackgroundUploadProgress currentProgress = upload.Progress; double percentSent = 100; if (currentProgress.TotalBytesToSend > 0) { percentSent = currentProgress.BytesSent * 100 / currentProgress.TotalBytesToSend; } var fileUploadProgress = new FileUploadProgress((long)currentProgress.BytesSent, (long)currentProgress.TotalBytesToSend, upload.TransferGroup.Name); FileUploadProgress(this, fileUploadProgress); if (currentProgress.HasRestarted) { // MarshalLog(" - Upload restarted"); } if (currentProgress.HasResponseChanged) { // We've received new response headers from the server. // If you want to stream the response data this is a good time to start. //upload.GetResultStreamAt(0); } }
public override void DidSendBodyData(NSUrlSession session, NSUrlSessionTask task, long bytesSent, long totalBytesSent, long totalBytesExpectedToSend) { var fileUploadProgress = new FileUploadProgress(totalBytesSent, totalBytesExpectedToSend); FileUploadProgress(this, fileUploadProgress); System.Diagnostics.Debug.WriteLine(string.Format("DidSendBodyData bSent: {0}, totalBSent: {1} totalExpectedToSend: {2}", bytesSent, totalBytesSent, totalBytesExpectedToSend)); }
private static void UploadProgress(UploadProgressChangedEventArgs e, string fileName, int id) { decimal pp = (decimal)e.BytesSent / (decimal)e.TotalBytesToSend; int percent = (int)Math.Round(pp * 100); if (percent > downloadProgressNextTick) { FileTransferProgressEventArgs args = new FileTransferProgressEventArgs(); args.PercentProgress = percent; args.ID = id; FileUploadProgress?.Invoke(null, args); downloadProgressNextTick = percent + downloadProgressTreshold; } }
public override void DidSendBodyData(NSUrlSession session, NSUrlSessionTask task, long bytesSent, long totalBytesSent, long totalBytesExpectedToSend) { string[] parts = task.TaskDescription.Split('|'); var tag = string.Empty; if (parts != null && parts.Length > 0) { tag = parts[0]; } var fileUploadProgress = new FileUploadProgress(totalBytesSent, totalBytesExpectedToSend, tag); FileUploadProgress(this, fileUploadProgress); System.Diagnostics.Debug.WriteLine(string.Format("DidSendBodyData bSent: {0}, totalBSent: {1} totalExpectedToSend: {2}", bytesSent, totalBytesSent, totalBytesExpectedToSend)); }
public void OnProgress(string tag, long bytesWritten, long contentLength) { var fileUploadProgress = new FileUploadProgress(bytesWritten, contentLength, tag); FileUploadProgress(this, fileUploadProgress); }
public UploadErrorModel(FileUploadProgress progress) { Ensure.NotNull(progress, "progress"); Progress = progress; }
public UploadImageModel(FileUploadProgress progress, ImageModel image) { Ensure.NotNull(progress, "progress"); Progress = progress; Image = image; }