truyền chu kì lấy thống kê qua tham số của constructor thay vì constant như trước
This commit is contained in:
parent
a7fe049f15
commit
8f8f5343e9
|
@ -9,7 +9,5 @@
|
|||
#endregion
|
||||
|
||||
public const string CAMERA_FAILED_IMAGE_PATH = @"Images\CantConnectCamera.jpg";
|
||||
|
||||
public const int TIME_TO_GET_STATISTIC_INFO = 60;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user