在 vb.net 中创建无限循环

Creating an infinate loop in vb.net

我正在考虑在 vb.net 中创建一个程序,该程序不断循环检查 .txt 文件中是否有 URL。然后应用程序将使用 HTTP Web 请求调用每个 URL(有点像 cron 作业)

但我希望它不断循环。让它不断运行是不是一个坏主意,目前我使用的是每 10 分钟运行一次的计时器

我会使用 FileSystemWatcher which was made for this purpose. You will be notified if the file changes in OnChanged

您可以使用 windows 服务,这里有一个教程:How to implement a simple filewatcher Windows service (in C# but you can use a converter like this)。

使用 windows 服务的优势:

  • 如果服务 运行s,它总是 运行ning,所以基本上是你的 "infinite loop"
  • 您可以控制启动进程的用户和权限
  • 可以定义失败策略(如果失败则尝试重新启动n次运行特定程序)