Hi,

I need help for my project.
I want to simulate a PLC process in VB.net which the process is running in a big loop.
What I try to make is calling 'Subroutines' and 'Functions' in a while loop after button 'Run' is pressed and stop after button 'Stop' is pressed.

in general, this is what I have done so far and it seems very heavy during the process. I guess that the Application.DoEvents() is the one that makes the program runs heavy.

HTML Code:
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click

btnStart.Enabled = False
While btnStart.Enabled = False 'chkG_bUnitAuto.Checked
            SubRoutines1()                          
            Application.DoEvents()
            SubRoutines2()                   
            Application.DoEvents()
            Functions1(nValue1)            
            Application.DoEvents()
            Functions2(nValue2)                            
            Application.DoEvents()
        End While
End Sub

Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
        btnStart.Enabled = True
        StopAll()
    End Sub
Do you guys maybe know what can I do to make it simple or maybe some ideas?