{"id":4802,"date":"2022-02-27T01:33:30","date_gmt":"2022-02-26T16:33:30","guid":{"rendered":"https:\/\/okamurax.com\/?p=4802"},"modified":"2022-02-27T01:33:30","modified_gmt":"2022-02-26T16:33:30","slug":"c-timer-%e4%b8%80%e5%ae%9a%e9%96%93%e9%9a%94%e5%ae%9f%e8%a1%8c","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=4802","title":{"rendered":"C# Timer \u4e00\u5b9a\u9593\u9694\u5b9f\u884c"},"content":{"rendered":"<pre class=\"lang:c# decode:true\">using System;\r\nusing System.Windows.Forms;\r\n\r\nnamespace BackupDb\r\n{\r\n    public partial class Form1 : Form\r\n    {\r\n        public Form1()\r\n        {\r\n            InitializeComponent();\r\n\r\n            Timer timer = new Timer();\r\n            DateTime start = DateTime.Now;\r\n\r\n            int counter = 0;\r\n            timer.Interval = 1000 * 5; \/\/ 5\u79d2\r\n            timer.Tick += (s, e) =&gt;\r\n            {\r\n                \/\/ \u5148\u305a5\u79d2\u5f8c\u306b1\u5ea6\u76ee\u300110\u79d2\u5f8c\u306b2\u5ea6\u76ee\u3060\u304c\u3001\r\n                \/\/ 2\u56de\u76ee\u304c9.9\uff5e\u306b\u306a\u308a\u30013\u56de\u8868\u793a\u3055\u308c\u308b\u3068\u304d\u304c\u3042\u308b\u3002\r\n\r\n                counter++;\r\n                TimeSpan ts = (DateTime.Now - start);\r\n                if (ts.TotalSeconds &gt;= 10) \r\n                {\r\n                    timer.Stop();\r\n                    MessageBox.Show(\"10\u79d2\u7d4c\u904e\u3057\u307e\u3057\u305f, \" + counter.ToString());\r\n                }\r\n                else\r\n                {\r\n                    MessageBox.Show(ts.TotalSeconds.ToString() + \", \" + counter.ToString());\r\n                }\r\n            };\r\n\r\n            timer.Start();\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>\u4e00\u5b9a\u9593\u9694\u3067\u5b9f\u884c\u3059\u308b\u5b9f\u9a13<\/p>\n","protected":false},"excerpt":{"rendered":"<p>using System; using System.Windows.Forms; namespace BackupDb { public partial class Form1 : Form { public Form &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=4802\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;C# Timer \u4e00\u5b9a\u9593\u9694\u5b9f\u884c&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9],"class_list":["post-4802","post","type-post","status-publish","format-standard","hentry","category-1","tag-c-net"],"_links":{"self":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/4802","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4802"}],"version-history":[{"count":1,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/4802\/revisions"}],"predecessor-version":[{"id":4803,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/4802\/revisions\/4803"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}