Пример #1
0
        private void RestartCalculation()
        {
            var srmDocument        = Document;
            var groupComparisonDef = GroupComparisonDef;

            if (_results != null)
            {
                if (Equals(_results.Document, srmDocument) && Equals(_results.GroupComparer.ComparisonDef, groupComparisonDef))
                {
                    return;
                }
            }
            if (null != _cancellationTokenSource)
            {
                _cancellationTokenSource.Cancel();
                _cancellationTokenSource = null;
            }
            if (0 == _modelChangedListeners.Count)
            {
                return;
            }
            if (_groupComparer == null || !Equals(srmDocument, _groupComparer.SrmDocument) ||
                !Equals(groupComparisonDef, _groupComparer.ComparisonDef))
            {
                _groupComparer = new GroupComparer(groupComparisonDef, srmDocument, _qrFactorizationCache);
            }
            _cancellationTokenSource = new CancellationTokenSource();
            if (null != GroupComparisonDef && null != Document)
            {
                _percentComplete = 0;
                GroupComparer groupComparer     = _groupComparer;
                var           cancellationToken = _cancellationTokenSource.Token;
                AddErrorHandler(Task.Factory.StartNew(() =>
                {
                    var results = ComputeComparisonResults(groupComparer, srmDocument, cancellationToken);
                    lock (_lock)
                    {
                        if (!cancellationToken.IsCancellationRequested)
                        {
                            Results          = results;
                            _percentComplete = 100;
                        }
                    }
                }, _cancellationTokenSource.Token));
            }
        }
Пример #2
0
 private void RestartCalculation()
 {
     var srmDocument = Document;
     var groupComparisonDef = GroupComparisonDef;
     if (_results != null)
     {
         if (Equals(_results.Document, srmDocument) && Equals(_results.GroupComparer.ComparisonDef, groupComparisonDef))
         {
             return;
         }
     }
     if (null != _cancellationTokenSource)
     {
         _cancellationTokenSource.Cancel();
         _cancellationTokenSource = null;
     }
     if (0 == _modelChangedListeners.Count)
     {
         return;
     }
     if (_groupComparer == null || !Equals(srmDocument, _groupComparer.SrmDocument) ||
         !Equals(groupComparisonDef, _groupComparer.ComparisonDef))
     {
         _groupComparer = new GroupComparer(groupComparisonDef, srmDocument, _qrFactorizationCache);
     }
     _cancellationTokenSource = new CancellationTokenSource();
     if (null != GroupComparisonDef && null != Document)
     {
         _percentComplete = 0;
         GroupComparer groupComparer = _groupComparer;
         var cancellationToken = _cancellationTokenSource.Token;
         AddErrorHandler(Task.Factory.StartNew(() =>
         {
             var results = ComputeComparisonResults(groupComparer, srmDocument, cancellationToken);
             lock (_lock)
             {
                 if (!cancellationToken.IsCancellationRequested)
                 {
                     Results = results;
                     _percentComplete = 100;
                 }
             }
         }, _cancellationTokenSource.Token));
     }
 }