用C#每小时检查一次网页

Kev*_*777 -3 c# visual-studio-express

我想编写一个每小时检查一次网页的脚本.我一直在关注SO的其他问题,每个人都在谈论使用:

static System.Windows.Forms.Timer t;
Run Code Online (Sandbox Code Playgroud)

有人可以帮帮我吗?

我很久没有在C#中做过多次编码,因为我最近一直在关注Unix和Linux.

任何帮助将不胜感激.

Dar*_*rov 5

using System;
using System.Net;
using System.Timers;

class Program
{
    static void Main()
    {
        Timer t = new Timer(TimeSpan.FromHours(1).TotalMilliseconds);
        t.Elapsed += (sender, e) =>
        {
            // This code will execute every hour
            using (var client = new WebClient())
            {
                // Send an HTTP request to download the contents of the web page
                string result = client.DownloadString("http://www.google.com");

                // do something with the results
                ...
            }
        };
        Console.WriteLine("press any key to stop");
        Console.ReadKey();
    }
}
Run Code Online (Sandbox Code Playgroud)