Solved

VB.Net - Cancel Button

Posted on 2014-03-10
5
396 Views
Last Modified: 2014-03-18
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
Comment
Question by:Jimbo99999
  • 2
  • 2
5 Comments
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
Is the long running process executing in a new Thread or is it executing in the button click event?
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
Possibly...it depends on how you started those "processes".
0
 

Author Comment

by:Jimbo99999
Comment Utility
Hello, thanks for responding.  They are all executed behind a button click.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
Perhaps you can show the code behind one of these buttons?
0
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now