public void Check(ICheckSettings settings, IDebugResourceWriter debugResourceWriter, FrameData frameData, IList <VisualGridSelector[]> regionSelectors, IEyesConnector connector, UserAgent userAgent, List <VisualGridTask> taskList, List <VisualGridTask> openTasks, RenderListener listener) { debugResourceWriter = debugResourceWriter ?? DebugResourceWriter ?? NullDebugResourceWriter.Instance; RenderingTask renderingTask = new RenderingTask(connector, frameData, regionSelectors, settings, taskList, openTasks, this, userAgent, debugResourceWriter, new RenderingTask.RenderTaskListener( () => { listener.OnRenderSuccess(); NotifyAllServices(); }, (e) => { NotifyAllServices(); listener.OnRenderFailed(e); }) ); Logger.Verbose("locking renderingTaskList"); lock (renderingTaskList_) { renderingTaskList_.Add(renderingTask); } Logger.Verbose("releasing renderingTaskList"); NotifyAllServices(); //Logger.Verbose("exit"); }
private void RunNextTask_() { if (!isServiceOn_) { return; } if (maximumPoolSize_ > concurrentSessions_) { logger_.Verbose("enter"); RenderingTask task = listener_.GetNextTask(); if (task != null) { logger_.Verbose("adding listener to task"); task.AddListener(new RenderingTask.RenderTaskListener(() => { DebugNotify_(); OnRenderFinish_(); }, (e) => { DebugNotify_(); OnRenderFinish_(); })); try { Interlocked.Increment(ref concurrentSessions_); Task <RenderStatusResults> resultTask = Task.Run(task.CallAsync); //activeRenderTasks_.Add(resultTask); // TODO - ITAI } catch (Exception e) { logger_.Verbose("Exception in - this.executor.submit(task);"); if (e.Message.Contains("Read timed out")) { logger_.Log("Read timed out"); } logger_.Log("Error: " + e); } } } else { lock (concurrencyLock_) { try { logger_.Verbose("Waiting for concurrency to be free"); Monitor.Wait(concurrencyLock_); logger_.Verbose("concurrency free"); } catch (Exception e) { logger_.Log("Error: " + e); } } } logger_.Verbose("exit"); }
private void Init() { TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; eyesOpenerService_ = new OpenerService("eyesOpenerService", Logger, concurrentOpenSessions_, openerServiceConcurrencyLock_, new EyesService.EyesServiceListener((tasker) => GetOrWaitForTask_(openerServiceLock_, tasker, "eyesOpenerService")), openerServiceInnerDebugLock_, openerServiceOuterDebugLock_, new EyesService.Tasker(() => GetNextTestToOpen_())); eyesCloserService_ = new EyesService("eyesCloserService", Logger, concurrentOpenSessions_, closerServiceInnerDebugLock_, closerServiceOuterDebugLock_, new EyesService.EyesServiceListener((tasker) => GetOrWaitForTask_(closerServiceLock_, tasker, "eyesCloserService")), new EyesService.Tasker(() => GetNextTestToClose_())); renderingGridService_ = new RenderingGridService("renderingGridService", Logger, concurrentOpenSessions_, renderServiceInnerDebugLock_, renderServiceOuterDebugLock_, new RenderingGridService.RGServiceListener(() => { RenderingTask nextTestToRender = GetNextRenderingTask_(); try { if (nextTestToRender == null) { Logger.Verbose("nextTestToRender is null. Waiting 300ms on lock object."); renderingServiceLock_.WaitOne(300); nextTestToRender = GetNextRenderingTask_(); } } catch (Exception e) { Logger.Log("Error: " + e); } return(nextTestToRender); }), renderingServiceLock_); eyesCheckerService_ = new EyesService("eyesCheckerService", Logger, concurrentOpenSessions_, checkerServiceInnerDebugLock_, checkerServiceOuterDebugLock_, new EyesService.EyesServiceListener((tasker) => GetOrWaitForTask_(checkerServiceLock_, tasker, "eyesCheckerService")), new EyesService.Tasker(() => GetNextCheckTask_())); }
private RenderingTask GetNextRenderingTask_() { Logger.Verbose("enter - renderingTaskList_.Count: {0}", renderingTaskList_.Count); RenderingTask renderingTask = null; if (renderingTaskList_.Count > 0) { Logger.Verbose("locking renderingTaskList_"); lock (renderingTaskList_) { if (renderingTaskList_.Count > 0) { renderingTask = renderingTaskList_[0]; renderingTaskList_.RemoveAt(0); Logger.Verbose("rendering task: {0}", renderingTask); } } Logger.Verbose("releasing renderingTaskList_"); } Logger.Verbose("exit"); return(renderingTask); }
//private string CraftUserAgent(RenderBrowserInfo browserInfo) //{ // BrowserType browserType = browserInfo.BrowserType; // string platform = StringUtils.ToPascalCase(browserInfo.Platform); // switch (browserType) // { // case BrowserType.CHROME: return "Mozilla/5.0 (" + platform + ") Chrome/0.0"; // case BrowserType.FIREFOX: return "Mozilla/5.0 (" + platform + ") Firefox/0.0"; // case BrowserType.IE_10: return "Mozilla/5.0 (" + platform + "; MSIE 10.0)"; // case BrowserType.IE_11: return "Mozilla/5.0 (" + platform + "; MSIE 11.0)"; // case BrowserType.EDGE: return "Mozilla/5.0 (" + platform + ") Edge/0.0"; // } // return "Mozilla/5.0 (" + platform + "; Unknown)"; //} internal void SetRenderingTask(RenderingTask renderingTask) { RenderingTask = renderingTask; }