vb.net - Error when closing my application in the middle of the loop -


here code loop:

do while potsstatus = true dim foregroundhwnd intptr = getforegroundwindow dim mysearchwinow intptr = findwindow(nothing, searchwindow) if foregroundhwnd = mysearchwinow     if rbq.checked = true         keybd_event(vbkeyq, 0, 0, 0)         keybd_event(vbkeyq, 0, keyeventf_keyup, 0)         thread.sleep(1)     elseif rbw.checked = true         keybd_event(vbkeyw, 0, 0, 0)         keybd_event(vbkeyw, 0, keyeventf_keyup, 0)         thread.sleep(1)     elseif rbe.checked = true         keybd_event(vbkeye, 0, 0, 0)         keybd_event(vbkeye, 0, keyeventf_keyup, 0)         thread.sleep(1)     elseif rbr.checked = true         keybd_event(vbkeyr, 0, 0, 0)         keybd_event(vbkeyr, 0, keyeventf_keyup, 0)         thread.sleep(1)     end if end if 

the problem when loop running , exit/close application encounters errors, process remains , loop never ends. thing can manually stop process in task manager. hope can me this.

edit: solved. made loop false in form closing event. thanks.

looking @ code can't see anywhere set potsstatus false (on aside don't need do while potsstatus = true, can do while potsstatus). need have mechanism letting loop know needs stop.

so on form close event set potsstatus false (assuming form wide variable). kind of looks thread candidate although without having better idea of code can't sure.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -