コード例 #1
0
ファイル: BackgroundQuery.cs プロジェクト: zrolfs/pwiz
 public void EnsureRunning()
 {
     lock (this)
     {
         if (_cancellationTokenSource == null)
         {
             _cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(new[] { QueryRequest.CancellationToken });
             var token = _cancellationTokenSource.Token;
             CommonActionUtil.RunAsync(() => Run(token));
         }
     }
 }
コード例 #2
0
        private void DoUpdateRemaining(CancellationToken cancellationToken)
        {
            btnOK.Enabled           = false;
            DocumentFinalCalculated = false;

            lblRemaining.Text     = Resources.PeptidesPerProteinDlg_UpdateRemaining_Calculating___;
            lblEmptyProteins.Text = string.Empty;

            var keepAll = KeepAll;

            numMinPeptides.Enabled = !keepAll;

            ActionUtil.RunAsync(() =>
            {
                var doc             = _document;
                var minPeptides     = MinPeptides;
                var removeRepeated  = RemoveRepeatedPeptides;
                var removeDuplicate = RemoveDuplicatePeptides;
                SrmDocument docFinal;
                try
                {
                    docFinal = GetDocumentFinal(cancellationToken, doc, minPeptides, removeRepeated, removeDuplicate,
                                                out _documentFinalEmptyProteins);
                }
                catch (OperationCanceledException)
                {
                    docFinal = null;
                }
                if (cancellationToken.IsCancellationRequested || docFinal == null)
                {
                    return;
                }
                CommonActionUtil.SafeBeginInvoke(this, () =>
                {
                    DocumentFinal           = docFinal;
                    DocumentFinalCalculated = true;
                    btnOK.Enabled           = true;

                    if (keepAll)
                    {
                        lblEmptyProteins.Text = string.Format(_emptyProteinsText,
                                                              DocumentFinalEmptyProteins.GetValueOrDefault());
                    }

                    int proteinCount, peptideCount, precursorCount, transitionCount;
                    NewTargetsFinal(out proteinCount, out peptideCount, out precursorCount, out transitionCount);
                    lblRemaining.Text = FormatCounts(_remaniningText, proteinCount, peptideCount, precursorCount,
                                                     transitionCount);
                });
            });
        }
コード例 #3
0
ファイル: ToolOptionsUI.cs プロジェクト: laeubisoft/pwiz
        private void UpdateServerStatus()
        {
            if (!IsHandleCreated)
            {
                return;
            }

            try
            {
                if (PrositIntensityModelCombo == null || PrositRetentionTimeModelCombo == null)
                {
                    _pingRequest?.Cancel();
                    SetServerStatus(ServerStatus.SELECT_MODEL);
                    return;
                }

                var pr = new PrositPingRequest(PrositIntensityModelCombo,
                                               PrositRetentionTimeModelCombo,
                                               _settingsNoMod, _pingInput.NodePep, _pingInput.NodeGroup, _pingInput.NCE.Value,
                                               () => { CommonActionUtil.SafeBeginInvoke(this, UpdateServerStatus); });
                if (_pingRequest == null || !_pingRequest.Equals(pr))
                {
                    _pingRequest?.Cancel();
                    _pingRequest = (PrositPingRequest)pr.Predict();
                    prositServerStatusLabel.Text      = PrositResources.ToolOptionsUI_UpdateServerStatus_Querying_server___;
                    prositServerStatusLabel.ForeColor = Color.Black;
                }
                else if (_pingRequest.Spectrum == null)
                {
                    SetServerStatus(_pingRequest.Exception == null ? ServerStatus.QUERYING : ServerStatus.UNAVAILABLE);
                }
                else
                {
                    SetServerStatus(ServerStatus.AVAILABLE);
                }
            }
            catch
            {
                SetServerStatus(ServerStatus.UNAVAILABLE);
            }
        }