Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. do loop hang and not resopnding while running langtime.how rectify this

do loop hang and not resopnding while running langtime.how rectify this

Scheduled Pinned Locked Moved Visual Basic
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    leostalin91
    wrote on last edited by
    #1

    I have picture box control.Using picture box.Height and picture box.Width in do loop i read the pixel information.**When i use large resolution image(height and width of the image is more)**it hang and not respond.how rectify this or set progress bar until the loop ends. dim i,j as integer dim img as image img=picturebox1.image do(i

    L S 3 Replies Last reply
    0
    • L leostalin91

      I have picture box control.Using picture box.Height and picture box.Width in do loop i read the pixel information.**When i use large resolution image(height and width of the image is more)**it hang and not respond.how rectify this or set progress bar until the loop ends. dim i,j as integer dim img as image img=picturebox1.image do(i

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      leostalin91 wrote:

      **When i use large resolution image(height and width of the image is more)**it hang and not respond.how rectify this or set progress bar until the loop ends.

      Would need to be executed on it's own thread, otherwise the UI-thread does not get the chance to repaint. The easiest way to do so, and add a progressbar, is using a BackgroundWorker[^].

      Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

      1 Reply Last reply
      0
      • L leostalin91

        I have picture box control.Using picture box.Height and picture box.Width in do loop i read the pixel information.**When i use large resolution image(height and width of the image is more)**it hang and not respond.how rectify this or set progress bar until the loop ends. dim i,j as integer dim img as image img=picturebox1.image do(i

        S Offline
        S Offline
        Syafrie007
        wrote on last edited by
        #3

        i think, you can add Application.doevents in ur looping.. :)

        D 1 Reply Last reply
        0
        • L leostalin91

          I have picture box control.Using picture box.Height and picture box.Width in do loop i read the pixel information.**When i use large resolution image(height and width of the image is more)**it hang and not respond.how rectify this or set progress bar until the loop ends. dim i,j as integer dim img as image img=picturebox1.image do(i

          S Offline
          S Offline
          Syafrie007
          wrote on last edited by
          #4

          i think, you can add Application.doevents in u looping.. :)

          1 Reply Last reply
          0
          • S Syafrie007

            i think, you can add Application.doevents in ur looping.. :)

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            That's the most dangerous way to do it as DoEvents will allow you to click other buttons and possibly make the code reentrant. The appropriate method is to farm the work off to a background thread.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak

            J 1 Reply Last reply
            0
            • D Dave Kreskowiak

              That's the most dangerous way to do it as DoEvents will allow you to click other buttons and possibly make the code reentrant. The appropriate method is to farm the work off to a background thread.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak

              J Offline
              J Offline
              josephSurgeon
              wrote on last edited by
              #6

              I agree with Dave you need to process this on a background thread so the UI can update itself.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups