0

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

Edited by ahmadzina85

3
Contributors
2
Replies
20
Views
3 Years
Discussion Span
Last Post by Reverend Jim
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.