コード例 #1
0
        private void GotLock(uint storeId)
        {
            lock (_jobLock)
            {
                if (_currentJobCompleted)
                {
                    // TODO - release lock?
                }

                if (_currentJob == null || storeId != _currentJob.StoreId)
                {
                    return;
                }

                // Ensure only run once
                if (_currentJob.StartedAt != null)
                {
                    return;
                }

                // If transfer has timed out, cancel it and release lock
                if (_currentJob.ExpiresAt.HasValue && _currentJob.ExpiresAt.Value < DateTime.Now)
                {
                    _currentJob = null;
                    ReleaseLock(storeId);
                    return;
                }

                ICommand cmd = _currentJob.Start(_currentId);
                if (cmd == null)
                {
                    // Release lock
                    if (_currentJob.StoreId != 0xffff) // If not macro
                    {
                        ReleaseLock(_currentJob.StoreId);
                    }

                    _currentJob = null;
                    DequeueAndRun();
                    return;
                }

                _connection.QueueCommand(cmd);
            }
        }
コード例 #2
0
ファイル: DataTransferManager.cs プロジェクト: FlsZen/LibAtem
        private void GotLock(uint storeId)
        {
            lock (_jobLock)
            {
                if (_currentJob == null || storeId != _currentJob.StoreId)
                {
                    // Don't need it
                    ReleaseLock(storeId);
                    // TODO - will we get stuck if we then never get our lock?
                    return;
                }

                // Ensure only run once
                if (_currentJob.StartedAt != null)
                {
                    return;
                }

                // If transfer has timed out, cancel it and release lock
                if (_currentJob.ExpiresAt.HasValue && _currentJob.ExpiresAt.Value < DateTime.Now)
                {
                    _currentJob = null;
                    ReleaseLock(storeId);
                    return;
                }

                _currentStartCommand = _currentJob.Start(_currentId);
                if (_currentStartCommand == null)
                {
                    // Release lock
                    ReleaseLock(_currentJob.StoreId);

                    _currentJob = null;
                    DequeueAndRun();
                    return;
                }

                _connection.QueueCommand(_currentStartCommand);
            }
        }