• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 422
  • Last Modified:

VB.Net - Cancel Button

Good Day Experts!

I have an application that has a main tab control.  Several of the tabs have longer running processes.  I do ask "Are you sure?" behind all of the button clicks, but several time Users click buttons then realize that they want to cancel.

The only way to get out of the process is to exit the application and go back in.

Is it possible to have a <Cancel> button on the UI to exit out of the current process?

Thanks,
jimbo99999
0
Jimbo99999
Asked:
Jimbo99999
  • 2
  • 2
1 Solution
 
Fernando SotoRetiredCommented:
Is the long running process executing in a new Thread or is it executing in the button click event?
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Possibly...it depends on how you started those "processes".
0
 
Jimbo99999Author Commented:
Hello, thanks for responding.  They are all executed behind a button click.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Perhaps you can show the code behind one of these buttons?
0
 
Fernando SotoRetiredCommented:
In that case what you can do is place a statement:

Application.DoEvents( )

In the program flow, with in a loop so that it can momentarily breakout of the executing code to handle the events, such as clicking a Cancel button then after the DoEvents check a variable set up by you in code to be the cancel variable. If this variable is true then have your code break out of the executing long process reseting the cancel variable just before leaving so it is ready for the next time. In the Cancel button set the cancel variable.

Please note that this will not work if within the button click event that run the long process is making a blocking call to some other system or a Database call that takes a long time because at that point you no longer have control but are waiting for a response.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now