Backgroundworker for recursive loop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kyawsithu
    New Member
    • Jan 2009
    • 3

    Backgroundworker for recursive loop

    Hi,

    I am new to windows application. Can anyone give me the answer on my issue? The issue is updating the progressbar of bgworker from recursive loop. The recursive loop is using to find the directory that I want to delete. Basically, the loop is working great also the bgworker has no problem I remove the update progress function. The error is exceeding the value of progressbar. Is there anyway to update the progressbar on the fly of directory search?

    Thanks
    Sithu
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    What do you mean by "The error is exceeding the value of progressbar"?

    Comment

    • IanWright
      New Member
      • Jan 2008
      • 179

      #3
      Originally posted by r035198x
      What do you mean by "The error is exceeding the value of progressbar"?
      He most likely means he is trying to set the ProgressBar.Val ue to a value larger than ProgressBar.Max Value.

      Firstly you need to check that you have initialized the MaxValue property with a sensible value, then you need to ensure that your logic isn't setting a silly value, 101% for example. If you want to be extra safe then doing a check before setting it

      if(value > ProgressBar.Max Value) { value = ProgressBar.Val ue;}

      Comment

      • kyawsithu
        New Member
        • Jan 2009
        • 3

        #4
        Re:

        Hi,

        Thanks for your answers. I would say straightly though, it is not the answer I expected. I am wondering how to set the max value of progresbar dynamically(the recursive loop could find unlimited directories in runtime). Is there any workaround?

        Thanks
        SiThu

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Well first make sure to be explicit on what you mean in your questions. As you can see there are mind readers with shiny crystal balls here who can read in between the lines to understand what you mean but it's best to be explicit so that mere mortals like me can also follow the conversation.
          So you don't know how many files are going to be searched but want to show progress in terms of percentage of work done so far? Well that's just impossible. To express a percentage to need what the total is supposed to be. Better throw away that idea altogether and just show the number of files searched so far like most file searchers do.

          Comment

          • kyawsithu
            New Member
            • Jan 2009
            • 3

            #6
            Yeah, you are right. Thank you

            Comment

            Working...