Exemplo n.º 1
0
        private void Loop()
        {
            while (true)
            {
                if (isCapturing && (appfind.IsTargetActive() || !isRecording))
                {
                    graph.Capture();

                    if (graph.IsScreenChanged() && (appfind.IsTargetActive() || !isRecording))
                    {
                        graph.UpdatePrevious();
                        if (isRecording)
                        {
                            ffmpeg.Write(graph.BmpToByte());
                        }

                        graph.UpdateIntPtr();

                        SpinWait.SpinUntil(() => false, CapInt);
                    }
                    else
                    {
                        SpinWait.SpinUntil(() => false, 500);
                    }
                }
                else
                {
                    SpinWait.SpinUntil(() => false, 500);
                }
            }
        }
Exemplo n.º 2
0
        private void Loop()
        {
            Stopwatch time = new Stopwatch();

            while (true)
            {
                time.Restart();

                if (isCapturing && (appfind.IsTargetActive() || !isRecording))
                {
                    graph.Capture();

                    if (graph.IsScreenChanged() && (appfind.IsTargetActive() || !isRecording))
                    {
                        graph.UpdatePrevious();
                        if (isRecording)
                        {
                            ffmpeg.Write(graph.BmpToByte());
                        }

                        graph.UpdateIntPtr();

                        time.Stop();
                        int timeLeft = CapInt - (int)time.Elapsed.TotalMilliseconds;
                        if (timeLeft > 0)
                        {
                            SpinWait.SpinUntil(() => false, timeLeft);
                        }
                    }
                    else
                    {
                        SpinWait.SpinUntil(() => false, 500);
                    }
                }
                else
                {
                    SpinWait.SpinUntil(() => false, 500);
                }
            }
        }