Exemple #1
0
        AcquireResult GetAcquireResult()
        {
            if (_acquireTask == null)
            {
                BeginAcquireFrame();

                return(null);
            }

            _acquireTask.Wait();

            lock (_acquireResultLock)
            {
                var val = _acquireResult;

                _acquireResult = null;

                return(val);
            }
        }
Exemple #2
0
        void BeginAcquireFrame()
        {
            const int timeout = 50;

            _acquireTask = Task.Run(() =>
            {
                try
                {
                    var result = _deskDupl.TryAcquireNextFrame(timeout, out var frameInfo, out var desktopResource);

                    if (result == ResultCode.WaitTimeout)
                    {
                        lock (_acquireResultLock)
                        {
                            _acquireResult = null;
                        }

                        BeginAcquireFrame();
                    }
                    else
                    {
                        lock (_acquireResultLock)
                        {
                            _acquireResult = new AcquireResult(result, frameInfo, desktopResource);
                        }
                    }
                }
                catch
                {
                    lock (_acquireResultLock)
                    {
                        _acquireResult = new AcquireResult(Result.Fail);
                    }
                }
            });
        }