How Do I Show Image Loading Progress in progress-bar c# -


I want to know how to load image load progress bar to show win form in progress bar.

my code is

  get private zero form 2_load (object sender, eventarges e) // load form and profile and avatar {background worker 1. Changed progress + = new progress changing event handler (background 1_ProgressChanged;); Background Type 1 Runwinner full + = new RunWorker compatible event handler (background 1 full-year work); BackgroundWorker1.RunWorkerAsync (); } Private Zero Background Worker 1_Worker (Object Sender, Runwalker Comprehensive Avant Eg E) {label2.Text = "Avatar Load"; } 1_ProgressChanged by Private Zero background (Object Sender, System.ComponentModel.ProgressChangedEventArgs e) // Show progress {if (InvokeRequired) {BeginInvoke (new action (=) = 1_ProgressChanged (sender, e)); } And {if (progress barcus 1. value! = Progression percentage) {progressBarX1.Value = E. Progress percentage; ProgressBarX1.Refresh (); }}} 1_DoWork (Object Sender, DoWorkEventArgs e) // Loading Avatar {WebClient wc = new WebClient (); Stream stream = wc.OpenRead ("http://avatar.nimbuzz.com/getAvatar?jid=" + textbox 1. text); PictureBox1.Image = (Image.FromStream (section)); }   

Image loading successfully but do not show any progress in the progress bar

Okay, I will use the event to change the progress of a webclient to get the result so that the progress of the download really is far away. So you can not save it from the background type thread, so when you get the file you have to do it.

Renew

  Private BackgroundWire BGW; Private Zero form1_load (object sender, eventAgds E) {bgw = new background player (); Bgw.DoWork + = bgw_DoWork; Bgw.WorkerReports Progress = true; Bgw.RunWorkerCompleted + = bgw_RunWorker contains; Bgv Changed progress + = bgw_Progress; Bgw.RunWorkerAsync (); } Zero bgw_ProgressChanged (object sender, progress progress eventArgs e) {progressBar1.Value = e.progressPercentage; } Contains zero bgw_RunWorker (Object Sender, RunWorkerCompletedEventArgs e) {pictureBox1.Image = (image) e. result; } Zero bgw_DoWork (object sender, DoWorkEventArgs e) {WebClient wc = New WebClient (); Wc.DownloadProgressChanged + = wc_DownloadProgressChanged; Stream stream = wc.OpenRead ("+ textBox1.Text"); E.Result = (Image.FromStream (stream)); } Zero wc_DownloadProgressChanged (Object Sender, DownloadProgressChangedEventArgs e) {bgw.ReportProgress (e.ProgressPercentage); }    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -