2016-04-04 24 views
1

我正在用bot連接器寫一個提醒機器人,它提醒我訂閱的YouTube頻道上傳新視頻的時間。我已經能夠獲得最新版本。但是,如果有新視頻並將鏈接作爲消息發送,我需要間隔檢查。 在特定時間間隔後發送郵件的最佳方式是什麼?用定時器發送郵件

+1

你的標題字面上回答你的問題 – Jonesopolis

回答

0
static void Main(string[] args) 
{ 
    var timer = new Timer(); 
    timer.Elapsed += GetLatestVideo; 
    timer.Enabled = true; 
    timer.Interval = 1000; 
    timer.Start(); 
} 

private static void GetLatestVideo(object sender, ElapsedEventArgs e) 
{ 
    // check video 

    // if video != latestVideo 
     // latestVideo = video 
     // send message 
}  

你會希望存儲ConnectorClient和變量的類最新的視頻包含此代碼,獲得更好的性能。但這是你如何添加一個區間。