Exemplo n.º 1
0
        public ImportJobController(ImportJobNewGen importJob, int importJobNumber, ImporterWorkerNewGen parentImporterWorker)
        {
            _importJobInformation = importJob.ImportJobInformation;
            _importJobNumber      = importJobNumber;
            _parentImporterWorker = parentImporterWorker;
            _numberOfLastPendingImportResource      = 0;
            _numberOfDisposedPendingImportResources = 0;
            _notifyProgress                = true;
            _pendingImportResources        = new ConcurrentDictionary <ResourcePath, PendingImportResourceNewGen>();
            _importJobControllerCompletion = new TaskCompletionSource <object>();
            _firstBlockHasFinished         = new TaskCompletionSource <object>();
            _cts = new CancellationTokenSource();
            _parentImporterWorker.NotifyProgress(true);

            _dataflowBlocks = new List <ImporterWorkerDataflowBlockBase>();
            SetupDataflowBlocks(importJob.PendingImportResources);
            _dataflowBlocks.ForEach(block => block.Completion.ContinueWith(OnAnyBlockFaulted, TaskContinuationOptions.OnlyOnFaulted));
            Task.WhenAll(_dataflowBlocks.Select(block => block.Completion)).ContinueWith(OnFinished);
        }
Exemplo n.º 2
0
    public ImportJobController(ImportJobNewGen importJob, int importJobNumber, ImporterWorkerNewGen parentImporterWorker)
    {
      _importJobInformation = importJob.ImportJobInformation;
      _importJobNumber = importJobNumber;
      _parentImporterWorker = parentImporterWorker;
      _numberOfLastPendingImportResource = 0;
      _numberOfDisposedPendingImportResources = 0;
      _notifyProgress = true;
      _pendingImportResources = new ConcurrentDictionary<ResourcePath, PendingImportResourceNewGen>();
      _importJobControllerCompletion = new TaskCompletionSource<object>();
      _firstBlockHasFinished = new TaskCompletionSource<object>();
      _cts = new CancellationTokenSource();
      _parentImporterWorker.NotifyProgress(true);

      _dataflowBlocks = new List<ImporterWorkerDataflowBlockBase>();
      SetupDataflowBlocks(importJob.PendingImportResources);
      _dataflowBlocks.ForEach(block => block.Completion.ContinueWith(OnAnyBlockFaulted, TaskContinuationOptions.OnlyOnFaulted));
      Task.WhenAll(_dataflowBlocks.Select(block => block.Completion)).ContinueWith(OnFinished);
    }