示例#1
0
        private void CaptureWithCursor(int interval)
        {
            var sw = new Stopwatch();

            while (_captureToken != null && !_captureToken.IsCancellationRequested)
            {
                sw.Restart();

                //Capture frame.
                var frame = new FrameInfo(RecordClicked, KeyList);
                KeyList.Clear();

                var frameCount = Capture.CaptureWithCursor(frame);
                Dispatcher.Invoke(() => FrameCount = frameCount);

                //If behind wait time, wait before capturing new frame.
                if (sw.ElapsedMilliseconds >= interval)
                {
                    continue;
                }

                while (sw.Elapsed.TotalMilliseconds < interval)
                {
                    Thread.Sleep(1);
                }

                //SpinWait.SpinUntil(() => sw.ElapsedMilliseconds >= interval);
            }

            sw.Stop();
        }
示例#2
0
        private void Cursor_Elapsed(object sender, EventArgs e)
        {
            FrameCount = _capture.CaptureWithCursor(new FrameInfo(_recordClicked, _keyList));

            _keyList.Clear();
        }