I just started learning wpf, so do not throw slippers :) I have a function that creates a new window with a progress bar, receives files via sftp (SSH.NET) and displays the progress of receiving these files. If you do this:
foreach (var file in files) { if (!file.IsDirectory && !file.IsSymbolicLink) { using (Stream fileStream = File.OpenWrite(System.IO.Path.Combine("photo_viewer_temp\\" + nowGetId.ToString(), file.Name))) { sftp.DownloadFile(file.FullName, fileStream); } } nowDownloaded++; downloadProgressBar.Value = nowDownloaded; progressTextBlock.Text = nowDownloaded.ToString() + " из " + filesCounter.ToString(); }
that window just hangs. The program loads and saves files, but the window is not updated, windows shows a round cursor ("thinks"). But if you do this:
foreach (var file in files) { if (!file.IsDirectory && !file.IsSymbolicLink) { using (Stream fileStream = File.OpenWrite(System.IO.Path.Combine("photo_viewer_temp\\" + nowGetId.ToString(), file.Name))) { sftp.DownloadFile(file.FullName, fileStream); } } nowDownloaded++; downloadProgressBar.Value = nowDownloaded; progressTextBlock.Text = nowDownloaded.ToString() + " из " + filesCounter.ToString(); MessageBox.Show("Debug"); }
Then everything starts to work. How to make it update without MessageBox?