vb.net - Jump out of code if a button is pressed -
is there way have 'listener' of sorts listen button click in middle of code? there scenarios won't have wait code complete before can exit functions cannot seem find way see if button clicked other throwing ton of if checks throughout function calls doesn't seem efficient me.
this code runs on thread, different main application
private function longrunningfunction() din canceled boolean = false ' make sure canceled while in loop ' long loop integer = 0 100000 if _cancelexecution canceled = true exit end if ' code runs here ......... next if canceled ' wrap thread, clean stuff, etc end if ....................... end function
on main thread, when button clicked _cancelexecution
set true
the backgroundworker
has mechanism built-in already
Comments
Post a Comment