Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.


manage thread to update UI Control

manage thread to update UI Control

All, I'm working on an app.
I have (C#) pdf page validator that evaluates the number of pages in a pdf file and compares it to the number entered on a form (the form will create an xml file used to configure an order).
My problem is that the process to run the validator against a large pdf file takes long enough that I would need to run it on a separate thread; but I can't seem to update / reference controls on the main UI Thread. The last thing I tried was the following.


Task taskA = Task.Factory.StartNew(() => DoSomeWork(5000));

I have also tried this


MainThread = SynchronizationContext.Current;
        if (MainThread == null) MainThread = new SynchronizationContext();

        MainThread.Send((object state) =>
            //pdfPageStatus.Text = pdfPages.ToString() + " pages in PDF File Uploaded";
            pdfPageStatus.Text = " pages in PDF File Uploaded";
            pdfPageStatus.ForeColor = Color.Blue;
        }, null); 

David Pimental
(US, Oh)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close