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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Stopping a running process (vb2005) while updating a progress bar

Stopping a running process (vb2005) while updating a progress bar

Scheduled Pinned Locked Moved Visual Basic
csharp
7 Posts 4 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.
  • V Offline
    V Offline
    Vivek Narayanan
    wrote on last edited by
    #1

    I'm writing an app in which a process(the vb .net component) is executed and a progressbar is updated simultaneously thru a do .. while loop . What i want to do is to add a cancel/stop button. In the stop button event code ,i've written code to 'kill' the running process . But when i execute the form ,the stop button (or for that matter any button) is not clickable,when the process and the do-while-loop code are running .Please Advice. Regards, Vivek

    V 1 Reply Last reply
    0
    • V Vivek Narayanan

      I'm writing an app in which a process(the vb .net component) is executed and a progressbar is updated simultaneously thru a do .. while loop . What i want to do is to add a cancel/stop button. In the stop button event code ,i've written code to 'kill' the running process . But when i execute the form ,the stop button (or for that matter any button) is not clickable,when the process and the do-while-loop code are running .Please Advice. Regards, Vivek

      V Offline
      V Offline
      Vasudevan Deepak Kumar
      wrote on last edited by
      #2

      You have a child thread to spawn. I would suggest instead of playing direct with threads, you can try using the SmartThreadPool component: http://www.codeproject.com/csharp/SmartThreadPool.asp[^]

      Vasudevan Deepak Kumar Personal Homepage Tech Gossips

      V 1 Reply Last reply
      0
      • V Vasudevan Deepak Kumar

        You have a child thread to spawn. I would suggest instead of playing direct with threads, you can try using the SmartThreadPool component: http://www.codeproject.com/csharp/SmartThreadPool.asp[^]

        Vasudevan Deepak Kumar Personal Homepage Tech Gossips

        V Offline
        V Offline
        Vivek Narayanan
        wrote on last edited by
        #3

        the control works only for c#,it doesn't work in vb,can u give me example code for creating threads.

        G 1 Reply Last reply
        0
        • V Vivek Narayanan

          the control works only for c#,it doesn't work in vb,can u give me example code for creating threads.

          G Offline
          G Offline
          GuyThiebaut
          wrote on last edited by
          #4

          I have come across the same situation you describe and using threads I coded it something like this:

          Public scanInformThread As Threading.Thread
          
          
          scanInformThread = New Threading.Thread(AddressOf Me.scanInformThreadProc)
          scanInformThread.Priority = Threading.ThreadPriority.Lowest
          scanInformThread.Start()
          
          While scanInformThread.IsAlive = True
          
          	check if cancel button is pressed
                  if it is pressed then scanInformThreadProc.Abort()
          	Yadayada Blahblah
          	make a cuppa coffee
          
          
          End While
          
          Sub scanInformThreadProc()
          
          	Yadayada Blahblah
          	do something useful like surf the web
          
          end sub
          

          Please excuse the pseudocode. Also note that this is not thread safe so you will need to put: Control.CheckForIllegalCrossThreadCalls = False at the beginning of your code to stop the compiler from whining at you. I hope this helps. Guy:) -- modified at 8:02 Wednesday 15th August, 2007 -- modified at 8:06 Wednesday 15th August, 2007

          You always pass failure on the way to success.

          M 1 Reply Last reply
          0
          • G GuyThiebaut

            I have come across the same situation you describe and using threads I coded it something like this:

            Public scanInformThread As Threading.Thread
            
            
            scanInformThread = New Threading.Thread(AddressOf Me.scanInformThreadProc)
            scanInformThread.Priority = Threading.ThreadPriority.Lowest
            scanInformThread.Start()
            
            While scanInformThread.IsAlive = True
            
            	check if cancel button is pressed
                    if it is pressed then scanInformThreadProc.Abort()
            	Yadayada Blahblah
            	make a cuppa coffee
            
            
            End While
            
            Sub scanInformThreadProc()
            
            	Yadayada Blahblah
            	do something useful like surf the web
            
            end sub
            

            Please excuse the pseudocode. Also note that this is not thread safe so you will need to put: Control.CheckForIllegalCrossThreadCalls = False at the beginning of your code to stop the compiler from whining at you. I hope this helps. Guy:) -- modified at 8:02 Wednesday 15th August, 2007 -- modified at 8:06 Wednesday 15th August, 2007

            You always pass failure on the way to success.

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

            hey you dont need to do the loop . just start the thread and end the function then on the buttons onclick event do a scanInformThreadProc.Abort() HTH Martin

            life is a bowl of cherries go on take a byte

            G 1 Reply Last reply
            0
            • M MartyK2007

              hey you dont need to do the loop . just start the thread and end the function then on the buttons onclick event do a scanInformThreadProc.Abort() HTH Martin

              life is a bowl of cherries go on take a byte

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

              You're right. I just hacked this out of my memory. Regards Guy

              You always pass failure on the way to success.

              V 1 Reply Last reply
              0
              • G GuyThiebaut

                You're right. I just hacked this out of my memory. Regards Guy

                You always pass failure on the way to success.

                V Offline
                V Offline
                Vivek Narayanan
                wrote on last edited by
                #7

                thanks , i will try this:-D

                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