Ejemplo n.º 1
0
        public ScreenshotCore(ICefConfig cefConfig, ILoggingService loggingService)
        {
            this.cefConfig                   = cefConfig;
            this.loggingService              = loggingService;
            this.lastPaintTimeStamp          = DateTime.UtcNow;
            this.isDisposed                  = false;
            this.client                      = new ScreenshotCefClient(this, cefConfig.ScreenshotWidth, cefConfig.ScreenshotHeight, loggingService);
            this.initializedCompletionSource = new TaskCompletionSource <bool>();
            this.screenshotQueue             = new BlockingCollection <ScreenshotRequestContext>();

            this.buffer    = new byte[cefConfig.ScreenshotHeight * cefConfig.ScreenshotWidth * 4];
            bufferGcHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned);

            this.screenshotWorkerCancellationSource = new CancellationTokenSource();
            Task.Factory.StartNew(() => ScreenshotWorker(this.screenshotWorkerCancellationSource.Token), TaskCreationOptions.LongRunning);
        }
Ejemplo n.º 2
0
        public ScreenshotCore(ICefConfig cefConfig, ILoggingService loggingService)
        {
            this.cefConfig = cefConfig;
            this.loggingService = loggingService;
            this.lastPaintTimeStamp = DateTime.UtcNow;
            this.isDisposed = false;
            this.client = new ScreenshotCefClient(this, cefConfig.ScreenshotWidth, cefConfig.ScreenshotHeight, loggingService);
            this.initializedCompletionSource = new TaskCompletionSource<bool>();
            this.screenshotQueue = new BlockingCollection<ScreenshotRequestContext>();

            this.buffer = new byte[cefConfig.ScreenshotHeight * cefConfig.ScreenshotWidth * 4];
            bufferGcHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned);

            this.screenshotWorkerCancellationSource = new CancellationTokenSource();
            Task.Factory.StartNew(() => ScreenshotWorker(this.screenshotWorkerCancellationSource.Token), TaskCreationOptions.LongRunning);
        }