如何在另一个按钮保存数据时单击另一个按钮? [英] How can I click an another button while the other button is saving a data?

查看:130
本文介绍了如何在另一个按钮保存数据时单击另一个按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个叫做打印按钮的1个按钮里面是很多验证,在行代码的最后是打印功能。如果通过要求验证数据需要10到15秒,我想减少等待时间,如果我有2个按钮,一个是保存按钮,用于验证数据,我等待,我可以点击打印按钮,如何我可以点击打印按钮,而另一个按钮(保存)正在保存/验证数据吗?



我尝试过:



i尝试尽可能减少行代码,但主要问题是连接服务器并验证数据是否通过了要求需要花费很多时间。

解决方案





将大任务(验证,保存,打印)拆分成的想法几个较小的任务总是好的。所以你的思维方式是正确的。现在您只需要进入多线程编程。这意味着创建一个线程并将保存操作指定为独立于主线程运行的线程,这将使您不会被保存过程阻止,然后您可以按照自己的想法设置单独的按钮进行打印。



如果这不能解决您的问题,请发表评论,我会帮助您改进我的解决方案,直到您的问题得到解决。



干杯,

AH


如何:在后台运行操作Microsoft Docs [ ^ ]。


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.

解决方案

Hi,

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.

Cheers,
AH


How to: Run an Operation in the Background | Microsoft Docs[^].


这篇关于如何在另一个按钮保存数据时单击另一个按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆