당신이이 같은 AutoResetEvent 사용할 수 있습니다 연결을 사용할 수 있는지 확인해야 기억
void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
//do stuff with the web call response
//signals locked thread that can now proceed
are.Set();
}
하고있는 경우, 가능한 예외를 처리 : 같아야합니다
protected override void OnInvoke(ScheduledTask task)
{
AutoResetEvent are = new AutoResetEvent(false);
//your asynchronous call, for example:
WebClient wc = new WebClient();
wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
wc.OpenReadAsync(searchUri, channel);
// lock the thread until web call is completed
are.WaitOne();
//finally call the NotifyComplete method to end the background agent
NotifyComplete();
}
및 콜백 방법을 백그라운드 에이전트가 메모리 소비 또는 지속 시간으로 인해 연속적으로 두 번 죽으면 OS에 의해 비활성화됩니다.