I transfer files and I want the progress bar to display the actual progress of each file. This works fine for files under the age of 15 megabytes, but the files are larger than it seems, causing my application to freeze. Unless I name this code for the progress bar, these large files are transmitted just fine.
I tried all sorts of ways to handle this with delegates, but no luck. Rather, they work fine with smaller files, but not larger ones.
Some examples that worked ...
pbFileProgress.Invoke((MethodInvoker) delegate { pbFileProgress.Value = args.PercentDone; });
In addition, this set of methods worked for small files.
private delegate void SetProgressBarCallback(int percentDone); public void UpdateProgressBar(object send, UploadProgressArgs args) { if (pbFileProgress.InvokeRequired) { var d = new SetProgressBarCallback(ProgressBarUpdate); BeginInvoke(d, new object[] { args.PercentDone }); } else { ProgressBarUpdate(args.PercentDone); } } public void ProgressBarUpdate(int percentDone) { pbFileProgress.Value = percentDone; }
But then again, everything just freezes if I try to enlarge the files.
source share