如何在asp.net中设置定时器延迟 [英] how to set timer delay in asp.net

查看:77
本文介绍了如何在asp.net中设置定时器延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



正在使用asp.net c#,



Iam使用url读取Xml文件,工作正常。



我的页面上有两个按钮,分别为ON和OFF。 br />


当我点击ON按钮时,xml文件中继状态将为1



as ....

Dear All,

am working on asp.net c#,

Iam reading Xml file using url,, its working fine.

I have two buttons on my page as ON and OFF.

When i click on ON button, the status of the xml file relay states will be 1

as....

<inputstates>000000000000000000</inputstates>
<relaystates>0000000000000001</relaystates>







当我的时候单击关闭状态o f XML文件中继状态为0






and when i click OFF the status of the XML file relay states will be 0

<inputstates>000000000000000000</inputstates>
<relaystates>0000000000000000</relaystates>





现在,我想在这些0和1之间放置10秒计时器

当我点击ON按钮时它应该是1并且在10秒后它应该是0,同样的事情必须继续。



请帮忙。



这是我的代码10秒



string url =http://10.10.14.44 /state.xml?relay1state=2&pulsetTime1=10;

XmlDocument xmlDoc = new XmlDocument();

xmlDoc.Load(url);





谢谢。



Now, i want to put 10 seconds timer between these 0 and 1
When i click ON button it should be 1 and after 10 seconds it should be 0, same thing must be continued.

Please help.

This is my code for 10 seconds

string url = "http://10.10.14.44/state.xml?relay1state=2&pulsetTime1=10";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(url);


thanks.

推荐答案

您好b $ b您可以尝试创建方法服务器端代码上的单独线程,它将调用与OFF按钮相同的方法。当你收到ON请求时,你需要在单独的线程中启动方法并将Thread.Sleep放置10秒。

在这种情况下,10秒后线程将继续他的工作并将调用OFF方法。 br />


希望这会有所帮助

最好的问候

Deverno
Hi You can try to create method in separate thread on your server side code which will call same method as your OFF button. when you receive ON request you need to start the method in separate thread and put Thread.Sleep with 10 seconds.
In this case after 10 seconds the thread will continue his work and will call OFF method.

Hope this will help
Best Regards
Deverno


这篇关于如何在asp.net中设置定时器延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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