From 8f8f5343e9a6158dc1bcfa4b8e1abb827545cd6b Mon Sep 17 00:00:00 2001 From: Le Chau Date: Thu, 25 Jun 2020 10:21:40 +0700 Subject: [PATCH] =?UTF-8?q?truy=E1=BB=81n=20chu=20k=C3=AC=20l=E1=BA=A5y=20?= =?UTF-8?q?th=E1=BB=91ng=20k=C3=AA=20qua=20tham=20s=E1=BB=91=20c=E1=BB=A7a?= =?UTF-8?q?=20constructor=20thay=20v=C3=AC=20constant=20nh=C6=B0=20tr?= =?UTF-8?q?=C6=B0=E1=BB=9Bc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AIParkingApplication/AppConstant.cs | 2 -- AIParkingApplication/Statistic.cs | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AIParkingApplication/AppConstant.cs b/AIParkingApplication/AppConstant.cs index 35d9780..e447052 100644 --- a/AIParkingApplication/AppConstant.cs +++ b/AIParkingApplication/AppConstant.cs @@ -9,7 +9,5 @@ #endregion public const string CAMERA_FAILED_IMAGE_PATH = @"Images\CantConnectCamera.jpg"; - - public const int TIME_TO_GET_STATISTIC_INFO = 60; } } diff --git a/AIParkingApplication/Statistic.cs b/AIParkingApplication/Statistic.cs index d5b598d..feb5142 100644 --- a/AIParkingApplication/Statistic.cs +++ b/AIParkingApplication/Statistic.cs @@ -10,6 +10,7 @@ namespace AIParkingApplication { private readonly HttpClient client; private readonly Thread thrStatistics; + private int timeCycle; Label lblLoaiXe; Label lblXeMay; @@ -18,9 +19,10 @@ namespace AIParkingApplication Label lblSoLuongXeMay; Label lblSoLuongOto; - public Statistic(string apiUrl) + public Statistic(string apiUrl, int timeCycle_Sec = 1) { InitializeComponent(); + timeCycle = timeCycle_Sec; ; client = new HttpClient { BaseAddress = new Uri(apiUrl), Timeout = TimeSpan.FromMilliseconds(5000) }; thrStatistics = new Thread(new ThreadStart(GetStatistic)) { IsBackground = true }; thrStatistics.Start(); @@ -31,7 +33,7 @@ namespace AIParkingApplication while (true) { GETDataFromServer(); - Thread.Sleep(AppConstant.TIME_TO_GET_STATISTIC_INFO * 1000); + Thread.Sleep(timeCycle * 1000); } }