Background task with huge data and progress bar

Hi Expert,
I have a background task which do lenghtly calculatio, how can I connect
my backgound task to GUI,and accept cancel button command?
I am using Vs2010, and TPL for creating task.

Thanks,
JT
jtran007Asked:
Who is Participating?
 
dericstoneCommented:
Oh, and about the cancel button, this code should give you an idea how to get started.
private bool isCancelButtonPressed = false;        
 
        private void myCancelBtn_Click(object sender, EventArgs e)
        {
          isCancelButtonPressed = true;
        }
...
 
        private void DoProcess()
        {
          for (int progress = 0; progress < 100; )
          {
            // Do a little work here 

            // Update the variable progress here depending on how much work was done

            UpdateProgressBarMethod(progress);

            if (isCancelButtonPressed)
              break;
          }
        }

Open in new window

0
 
jtran007Author Commented:
Hi Expert,

Sionce I use Task Parallel Library to do background task. How can I setup the GUI task talk to
TPL task?

Thanks,
JT
0
 
jtran007Author Commented:
Thanks,
JT
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.