1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Timers; using System.Net; using System.IO; namespace ConsoleApp4 { class Program { static void Main(string[] args) { Timer timer = new System.Timers.Timer(); timer.Interval = 1000 * 10; // 10초 timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); timer.Elapsed += new ElapsedEventHandler(print_Woonggon); timer.Start(); Console.WriteLine("Press enter to exit"); Console.ReadLine(); } static void timer_Elapsed(object sender, ElapsedEventArgs e) { WebClient web = new WebClient(); string webpage = web.DownloadString("https://www.csharpstudy.com/Threads/timer.aspx"); string time = DateTime.Now.ToString("yyyyMMdd_hhmmss"); string outputFile = string.Format("page_{0}.html", time); File.WriteAllText(outputFile, webpage); } static void print_Woonggon(object sender, ElapsedEventArgs e) { Console.WriteLine("Hello woonggon"); } } } | cs |
'C#' 카테고리의 다른 글
c# thread lock 명령어로 critical section 조절하기 (0) | 2021.11.07 |
---|---|
c# winform UI스레드, Worker스레드 (0) | 2021.11.07 |
c# winform timer (0) | 2021.11.07 |
c# winform backgroundworker 스레드 중단/재개하기 코드 (1) | 2021.11.06 |
c# winform chart(only for .net framework) (0) | 2021.11.06 |