Ejemplo n.º 1
0
        public void Start()
        {
            IsRunning = true;

            _worker = new BackgroundWorker();
            _worker.DoWork += (sender, args) => { args.Result = CaptureAndSleep(); };
            _worker.RunWorkerCompleted += (sender, args) =>
            {
                var capturedEventArgs = new ScreenCapturedEventArgs(args.Result as BitmapSource);
                OnScreenCaptured(capturedEventArgs);
                if (IsRunning)
                {
                    _worker.RunWorkerAsync();
                }
            };

            _worker.RunWorkerAsync();
        }
Ejemplo n.º 2
0
 void OnScreenCaptured(ScreenCapturedEventArgs e)
 {
     EventHandler<ScreenCapturedEventArgs> handler = ScreenCaptured;
     if (handler != null)
     {
         handler(this, e);
     }
 }