Bonjour,
il nous faudrait le code de ta fonction oui.
Par ailleurs, étant donné que tu exécutes la fonction "mySetProgressBarDelegate" dans un autre thread, il ne pourra normalement pas accéder à la ProgressBar qui est dans un autre thread. Il faut donc faire un appel au Dispatcher pour revenir au thread graphique :
Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(mySetProgressBarDelegate("tes paramètres"));
ou tu peux écrire tout ca directement dans le corps de ta fonction :
1 2 3 4 5 6 7
| private void SetProgressBarValue(int iMaxValue, int iValue, int iStepValue, int iMinValue)
{
Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { myProgressBar.Maximum = iMaxValue; }));
Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate {myProgressBar.Value = iValue;}));
Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { myProgressBar.Step = iStepValue;}));
Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate {myProgressBar.Minimum = iMinValue;}));
} |
Que tu peux aussi déclencher avec un évènement au lieu d'un delegate si tu te trouves dans une autre classe.
Ca ne résout toujours pas le problème de pourquoi ca reste bloqué, mais en tout cas c'est comme ca qu'il faut faire. (Pour info il me semble que Dispatcher.Invoke est asynchrone et BeginInvoke est synchrone si tu préfères changer).
Partager