I would like to show a ProgressBar when I call a method, so I have try to do this code:
if (parametro.chiave == "VIDEO") { //BISOGNA CARICARE IL VIDEO String urlVideo=caricaVideoOnline(parametro.valore); .... } String caricaVideoOnline(string nomeFileVideo) { try { libreriaYouTube = new UploadVideo(ConfigurationManager.AppSettings["usernameYoutube"], ConfigurationManager.AppSettings["passwordYouTube"], ConfigurationManager.AppSettings["developmentKeyYouTube"], ConfigurationManager.AppSettings["applicationNameYouTube"]); libreriaYouTube.listaVideoToUpload.Add(nomeFileVideo); // String video = libreriaYouTube.caricaVideo(); Thread t = new Thread(delegate() { for (int i = 0; i < 100000; i++) { if (i == 0) { ProgressBar progress = new ProgressBar(); progress.Show(); } Console.WriteLine(i); } }); t.SetApartmentState(ApartmentState.STA); t.Start(); String video= libreriaYouTube.caricaVideo(); video = libreriaYouTube.caricaVideo(); return video; } catch (Exception e) { log.Error(e); return null; } } This code found but I show the ProgressBar but it is locked, I don't see the bar run.
This is a code of ProgressBar.xaml
<Window x:Class="Gestore.ProgressBar" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Caricamento video" Height="100" Width="300" > <Grid Margin="20"> <ProgressBar Minimum="0" Maximum="100" Name="pbStatus" IsIndeterminate="True" Tag="Attendere....."/> <Viewbox> <TextBlock Text='Attendere ...' FontSize="2" x:Name="textVox"/> </Viewbox> </Grid> </Window>