hey,I have two buttons Start button and Stop button .I run my program by clicking on start button. I want to stop the program during the start button . But the program will not responde until the start buttun finish its job. How i can do check the stop buttun during the start. i heard about threading but i do not know how i can do it. Please

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button3.Click
 //my code
 //check always if the user push stop if no continue if yes go to this sub
 //my code
 end sub



     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        stopClick = True

        Dim Response As Integer

        Response = MessageBox.Show("Do you really want to exit?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

        If Response = vbYes Then

            Me.Close()

        End If


    End Sub

Recommended Answers

All 2 Replies

Have you tried if application.doevents works for you? I've never used it in vb.net, but in vba it would do what you expect.

Look at the documentation here : http://msdn.microsoft.com/en-us/library/system.windows.forms.application.doevents(v=vs.110).aspx

Not sure it's "best pactices" though.

You're better off use threads and the "backgroundworker". See if this http://msdn.microsoft.com/en-us/library/vstudio/system.componentmodel.backgroundworker works for you and let us now.

Good luck.

In the last week or so I posted a new tutorial on creating and managing background threads. You can find it here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.