如何让我的计时器首次启动运行应用程序启动时 [英] How Do I Get My Timer To Start Running Only The First Time The Application Is Started

查看:110
本文介绍了如何让我的计时器首次启动运行应用程序启动时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我目前需要为我的程序开发一个导入模块,每小时运行一次。每天运行一次。



我的应用程序是一个基于Web的应用程序

我已经编码了导入模块。

我有一个计时器设置为每小时运行一次。



我在Global.asax.vb文件中添加了代码,但我遇到了无数问题。



我添加了代码调用类并让计时器启动



因为某些奇怪的原因我遇到了问题,调试定时器的方法被调用并且定时器开始运行但到了10-15秒后,该过程还没有完成,但调试器将我带回全局页面并且代码再次开始运行,我遇到的问题不仅是它复制了需要导入的数据吗?导致问题,因为它正在尝试读取和导入的文件仍然被启动10-15秒b的进程读取之前。



首次运行程序时,我可以选择启动计时器吗?



此外,我已经测试了我的代码运行它通过一个普通的GUI与计时器,我没有任何issuses,我也尝试运行代码没有计时器仍然有相同的问题

Hi
I currently need to develop an import module for my program that runs every hour.and one that runs daily.

My application is a web based application
I have the coded the import module.
I have a timer which is set to run every hour.

I added code in the Global.asax.vb file but i am having endless issues.

I have added code to call the class and get the timer to start

I am having a problem for some strange reason while debugging the method of the timer gets called and the timer starts running but by 10-15 seconds later the process has not even finished yet but the debugger takes me back to the Global page and the code start running again ,issue i am having with this is not only is it duplicating data that need to be imported it causes an issues because the file it is trying to read and import is still being read by the process which started 10-15 seconds before.

Is there an alternative for me to start my timer when the program is first run?

Also i have tested my code running it through a normal GUI with the timer and i dont have any issuses, i have also tried running the code without the timer still having the same issue

推荐答案

任务计划程序是Windows的默认功能,因此无需构建其他应用程序。查看此链接以获取更多信息:

http://www.dummies.com/how-to/content/how-to-open-windows-task-scheduler.html [ ^ ]



祝你好运!
Task Scheduler is a default feature of windows so no need to build another application. Check this link for more info:
http://www.dummies.com/how-to/content/how-to-open-windows-task-scheduler.html[^]

Good luck!


既然你提到global.asax这就意味着它是ASP.Net。你应该这样标记它。



ASP.Net不是按计划运行的好平台。这是因为网络是断开连接的媒介,这意味着您的代码只会在有人试图访问您的某个网页时运行。然后代码将停止并且什么都不做,直到有人试图再次访问页面。



请参阅解决方案1以安排项目。使用任务调度程序很容易。您甚至可以编写一个简单的控制台应用程序甚至是Windows服务,但ASP.Net不是正确的技术。
Since you mention global.asax this means it is ASP.Net. You should have tagged it as such.

ASP.Net is not a good platform for running things on a schedule. This is because the web is a disconnected medium meaning your code will only run when someone tries to visit one of your pages. Then the code will stop and do nothing until someone tries to get to a page again.

See solution 1 for scheduling items. It's easy to use task scheduler. You could even write a simple console application or even a windows service but ASP.Net is not the right technology.


这篇关于如何让我的计时器首次启动运行应用程序启动时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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