public void request(IRequestMonitor monitor, WebPageModel page, HandWebDataTask handTask, RepeatInfo repeatInfo, PassingData data) { if (page == null) { return; } //Cancel Previous ensureCancelCTS(); cacheCTS = new CancellationTokenSource(); var token = cacheCTS.Token; //Create Monitor if (monitor == null) { monitor = new RequestMonitor(); } //Request var httpRequest = provideRequestTask(page.IsPost); var requestInfo = new HttpRequestInfo() { RequestTask = httpRequest, HttpRequestConfig = httpConfig, RequestMonitor = monitor, HandDataTask = handTask, Page = page, Passing = data, RepeatInfo = repeatInfo, Token = token }; monitor.IsTaskEmpty = false; monitor.IsTaskWaiting = false; Task.Run(() => loopingRequest(requestInfo).ContinueWith(task => { ensureCancelCTS(); monitor.IsTaskWaiting = false; monitor.IsTaskEmpty = true; monitor.IsRequesting = false; if (task.IsCanceled) { monitor.OnTaskCanceled(); } else if (task.IsFaulted) { if (task.Exception.GetBaseException() != null) { monitor.OnFaulted(task.Exception.GetBaseException()); } } })); }
public void request(IRequestMonitor monitor, WebPageModel page, HandWebDataTask handTask, PassingData data) { request(monitor, page, handTask, RepeatInfo.Once, data); }