Click here to Skip to main content
15,883,694 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a 1 button called print button inside of it is a lot of validation an in the end of the line code is the print function. Validating the data if it pass the requirements takes 10 to 15 seconds, i want to reduce the waiting time, what if i have 2 buttons the one is save button for validation of the data and while i wait i can click the print button, how can i click the print button while the other button (save) is saving/validating the data?

What I have tried:

i tried to reduce the line code as much as i can but the main problem is that connecting in the server and validating the data if it pass the requirements is taking to much time.
Updated 14-Nov-18 23:09pm


The idea of splitting a big task (validation, save, print) into several smaller tasks are always good. So the way that you are thinking is correct. Now you just need to step in Multi-thread programming. This means create a thread and assign the save action to that to run independently of the main thread, this will let you to not be blocked by the save process then you can follow your own idea of having a separate button for print.

If this did not solve your problem then please leave a comment and I will assist you by improving my solution until your problem gets solved.

Share this answer
jsc42 15-Nov-18 5:31am    
Multi-threading is the correct way to go, but as a quick hack you can (often, but not always) get away with Application.DoEvents. If you do go down this slightly risky route, disable the Save button when pressed and reenable it when saving is completed; otherwise impatient users will keep pressing it.
Aydin Homay 15-Nov-18 5:56am    
Then the end user should wait for 10 to 15 seconds !!!
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900