Click here to Skip to main content
15,888,283 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

I have a question .

I have written a small programm to programm RFID Cards.
There is a funtion in the software of the cardreader that is checking if there is a card on the reader.
So when i click the button on the screen programm card , i put in a Do loop function to check if there is a card on the reader , if there is a card i go to the next programming function. When there is no card Yet i keep in the loop.
This is working like it should be but is need to implement some button on the screen so when clicking on the button 'Cancel' that the loop is stopped.

So when the user don't want to program the card anyway so that he can escape from the do loop by clicking on the 'Cancel' button.

What is the best and correct way to do something like this.

Tanks.


br.

Didier
Posted

Running your loop on a BackgroundWorker should make it easier for you to handle this situation.
See here[^].
 
Share this answer
 
Try this simple code:

VB
Public Class Form1
    Dim FlagCancel As Boolean
    Private Sub Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start.Click
        FlagCancel = False
        Do While FlagCancel = False
            My.Application.DoEvents()
        Loop
    End Sub
    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        FlagCancel = True
    End Sub
End Class
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900