KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm stuck trying to update a progressbar from other threads ran in a different class. To explain what I do I think a picture will be better. I want to update the progressbar in the //HERE point : I've tried using a delegate, tried with ReportProgress and I think i've basically tried to use everything google reported in the first 100 results, without success. I'm still learning WPF and this might be silly way to proceed, i'm looking for a quick and dirty way to get the work done but feel free to tell me what I should redesign for a cleaner application. EDIT : More code. In ExecutorWindow.xaml.cs : public void RunExecutor() { // CREATE BACKGROUNDWORKER FOR EXECUTOR execBackground.DoWork += new DoWorkEventHandler(execBackground_DoWork); execBackground.RunWorkerCompleted += new RunWorkerCompletedEventHandler(execBackground_RunWorkerCompleted); execBackground.ProgressChanged += new ProgressChangedEventHandler(execBackground_ProgressChanged); execBackground.WorkerReportsProgress = true; execBackground.WorkerSupportsCancellation = true; // RUN BACKGROUNDWORKER execBackground.RunWorkerAsync(); } private void execBackground_DoWork(object sender, DoWorkEventArgs e) { myExecutor = new Executor(arg1, arg2); myExecutor.Run(); } private void execBackground_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { MessageBox.Show("RunWorkerCompleted execBackground"); } private void execBackground_ProgressChanged(object sender, ProgressChangedEventArgs e) { ExecutorProgressBar.Value += 1; } // TESTING private void updateProgressBar(int i) { ExecutorProgressBar.Value += i; } public delegate void callback_updateProgressBar(int i); In Executor.cs : public void Run() { string[] options = new string[2]; int i = 0; while (LeftToR
Tags (comma-separated)
Save Edits
Cancel