Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Refreshing a textbox
Message
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Versions des environnements
Environment:
C# 4.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01605402
Message ID:
01605408
Vues:
49
>It seems that just setting Status.Text=someValue from within a click event does not (vfp) refresh until the event is completed. How can this be done (in C#) if one wants to show the status of a multistage procedure by setting the Status.Text?

If I understand correctly then you need to use a background worker to keep the UI responsive. e.g.:
var b= new BackgroundWorker();
            b.WorkerReportsProgress = true;
            b.ProgressChanged += (o, args) => { Status.Text = args.UserState.ToString(); };
            b.DoWork += (o, args) =>
                {
                    var bw = o as BackgroundWorker;
                    bw.ReportProgress(0, "Started");
                    System.Threading.Thread.Sleep(1000);
                    bw.ReportProgress(0, "Stage 1");
                    System.Threading.Thread.Sleep(1000);
                    bw.ReportProgress(0, "Stage 2");
                    System.Threading.Thread.Sleep(1000);
                    bw.ReportProgress(0, "Finished");
                };
            b.RunWorkerAsync();
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform