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. Progress Window for long mainThread operation, Windows Forms

Progress Window for long mainThread operation, Windows Forms

Scheduled Pinned Locked Moved Visual Basic
winforms
6 Posts 3 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.
  • M Offline
    M Offline
    maksim310
    wrote on last edited by
    #1

    Hi, My application requires a long process of going through selected rows in the DataGridView and calculating things, this must be done on the main GUI thread. The user needs to be able to cancel this process but otherwise not have any interaction with the main GUI. I need a popup Progress Window (progressBar, label,cancelButton...) that will tell the user how much of the process is done and give them a chance to cancel. I think I need to create a new thread that will launch a progress window, the progress window will launch a process located on the main thread, and the main thread will comunicate back to the progress window how things are going. I've lookedd for many tutorials but they've all focused on running work on background threads using public variables. Also, I am still very new to programming and this is m first real application. I ask you explain things in as much detail as possible. Thank you!

    G 1 Reply Last reply
    0
    • M maksim310

      Hi, My application requires a long process of going through selected rows in the DataGridView and calculating things, this must be done on the main GUI thread. The user needs to be able to cancel this process but otherwise not have any interaction with the main GUI. I need a popup Progress Window (progressBar, label,cancelButton...) that will tell the user how much of the process is done and give them a chance to cancel. I think I need to create a new thread that will launch a progress window, the progress window will launch a process located on the main thread, and the main thread will comunicate back to the progress window how things are going. I've lookedd for many tutorials but they've all focused on running work on background threads using public variables. Also, I am still very new to programming and this is m first real application. I ask you explain things in as much detail as possible. Thank you!

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      maksim310 wrote:

      this must be done on the main GUI thread

      Why do you think so?

      maksim310 wrote:

      I think I need to create a new thread that will launch a progress window

      No, that's not possible. Only the GUI thread can open windows.

      Despite everything, the person most likely to be fooling you next is yourself.

      M 1 Reply Last reply
      0
      • G Guffa

        maksim310 wrote:

        this must be done on the main GUI thread

        Why do you think so?

        maksim310 wrote:

        I think I need to create a new thread that will launch a progress window

        No, that's not possible. Only the GUI thread can open windows.

        Despite everything, the person most likely to be fooling you next is yourself.

        M Offline
        M Offline
        maksim310
        wrote on last edited by
        #3

        So what's the best way to do this then? I'm going to be coloring 5000 data grid view rows different colors, I need to show the user the progress.

        D G 2 Replies Last reply
        0
        • M maksim310

          So what's the best way to do this then? I'm going to be coloring 5000 data grid view rows different colors, I need to show the user the progress.

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

          maksim310 wrote:

          I'm going to be coloring 5000 data grid view rows different colors

          Why color so many rows when the user is only going to see a few at a time?? You got some ginormous monitor you're not telling us about?

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008

          M 1 Reply Last reply
          0
          • D Dave Kreskowiak

            maksim310 wrote:

            I'm going to be coloring 5000 data grid view rows different colors

            Why color so many rows when the user is only going to see a few at a time?? You got some ginormous monitor you're not telling us about?

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007, 2008

            M Offline
            M Offline
            maksim310
            wrote on last edited by
            #5

            Only 15 or so rows will be seen at once, but the Data Grid View will be displaying all 5000 rows and the user will be scrolling looking for certain patterns. This is a scientific program where users will be generating copious amounts of color-coded rows and will need to detect patterns as they scroll. THe only other way I can think of is to paint them as they scrool by, but that might be too slow as well as constantly hang up the GUI. -Max

            1 Reply Last reply
            0
            • M maksim310

              So what's the best way to do this then? I'm going to be coloring 5000 data grid view rows different colors, I need to show the user the progress.

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #6

              Do the work in a background thread and store the results in a synchronised queue. Run a timer in the GUI thread that get the result from the queue and puts them in the grid. Search the forum for SynchronisedQueue, and you'll find an implementation that I did a while back.

              Despite everything, the person most likely to be fooling you next is yourself.

              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