private void DispatchFileSystemTreeComputing(TypedEvent typedEvent)
        {
            var @event = typedEvent as FileSystemTreeComputing;

            if (@event != null)
            {
                WpfUtilities.Post(this, () => {
                    Logger.LogInfo("FileSystemTree is being computed on server.");
                    _progressBarTracker.Start(OperationsIds.FileSystemTreeComputing,
                                              "Loading files and directory names from file system.");
                    Controller.OnFileSystemTreeComputing();
                });
            }
        }
Пример #2
0
        private void SearchWorker(SearchWorkerParams workerParams)
        {
            // Cancel all previously running tasks
            _taskCancellation.CancelAll();
            var cancellationToken = _taskCancellation.GetNewToken();

            var id         = Interlocked.Increment(ref _operationSequenceId);
            var progressId = string.Format("{0}-{1}", workerParams.OperationName, id);
            var sw         = new Stopwatch();
            var request    = new DispatchThreadServerRequest {
                // Note: Having a single ID for all searches ensures previous search
                // requests are superseeded.
                Id               = "MetaSearch",
                Request          = workerParams.TypedRequest,
                Delay            = workerParams.Delay,
                OnThreadPoolSend = () => {
                    sw.Start();
                    _progressBarTracker.Start(progressId, workerParams.HintText);
                },
                OnThreadPoolReceive = () => {
                    sw.Stop();
                    _progressBarTracker.Stop(progressId);
                },
                OnDispatchThreadSuccess = typedResponse => {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return;
                    }
                    workerParams.ProcessResponse(typedResponse, sw);
                },
                OnDispatchThreadError = errorResponse => {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return;
                    }
                    workerParams.ProcessError(errorResponse, sw);
                }
            };

            _dispatchThreadServerRequestExecutor.Post(request);
        }