Timer 개체를 사용하여 주기적 서비스 검사를 트리거 할 수 있습니다. Elapsed 이벤트에서 서비스 쿼리를 실행할 수 있습니다. 텍스트 상자에 상태를 표시로서
private void t_Elapsed(object sender, ElapsedEventArgs e)
{
// Check service statuses
}
, 당신은 일반 텍스트 상자에 서비스 상태에 toString() 메서드를 사용하고 표시 할 수 있어야한다. 타이머 이벤트에 반응 할 때 GUI 스레드에있을 수도 있고 없을 수도 있으므로 메인 스레드로 직접 호출해야합니다.
private delegate void TextUpdateHandler(string updatedText);
private void UpdateServerStatuses(string statuses)
{
if (this.InvokeRequired)
{
TextUpdateHandler update = new TextUpdateHandler(this.UpdateServerStatuses);
this.BeginInvoke(update, statuses);
}
else
{
// load textbox here
}
}