CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2001
    Location
    AZ
    Posts
    201

    [RESOLVED] How to update a ToolStripProgressBar from a thread

    I have a Windows form that has a StatusStrip that contains a ProgressBar. I want to update the ProgressBar from a thread started by the form when a treeview item is clicked on. I set up a delegate and a method to issue the PerformStep() but the compiler tells me that the ToolStripProgressBar does not contain a definition for Invoke.

    How do I update the progress bar?

    Thanks in advance,
    Hal
    Last edited by HalD; April 2nd, 2007 at 10:28 PM. Reason: Change title
    up·grade (up'gräd'),
    to take out old bugs
    and put in new ones.

  2. #2
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: How to update a ToolStripProgressBar from a thread

    Use a BackgroundWorker, and update the progressbar from the worker's progresschanged event, which is UI thread safe

    If youre on 1.1 .net and dont have a BGW, you can get one by googling; its not part of the framework.
    If youre on 1.0, upgrade

    If you dont want to upgrade, you can call InvokeRequired on the form itself, and if it is needed, Invoke a method tha tupdates the progressbar. Pointless though, when background worker makes it so nice, and painless
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured