지연자동 조회 처리
조회 조건이 바뀔때 조회를 버튼클릭없이 자동으로 하도록 하는 처리임.
이때 조회 조건이 일정 시간내에 다른 항목이 변경시 다시 조회대기시간을 늘려서 바로 조회가 일어나지 않도록 한다.
## 조회 항목이 변경될때마다 DelayQuery(); 호출해주면서 조회 대기시간이 초기화 되도록 처리함.
한번 호출되면 일정시간을 대기한 후 입력이 없으면 조회를 실행한다.
################################### 지연 쿼리 ########################
#region 지연 쿼리호출
bool isDelayRun = false;
DateTime triggerTime = DateTime.MaxValue;
void DelayCheckFunction()
{
while (isDelayRun)
{
var Span = DateTime.Now - triggerTime;
if (Span.Seconds >= 1)
{
Action query = 조회_메서드명;
Dispatcher.BeginInvoke(query, System.Windows.Threading.DispatcherPriority.Render, null);
isDelayRun = false;
}
System.Threading.Thread.Sleep(100);
}
}
void DelayQuery()
{
triggerTime = DateTime.Now;
if (isDelayRun == false)
{
isDelayRun = true;
Action chkAction = DelayCheckFunction;
chkAction.BeginInvoke(null, chkAction);
}
}
#endregion