Exemplo n.º 1
0
        private void TaskTerminated(object sender, BackgroundTaskTerminatedEventArgs args)
        {
            if (_dicomPrintSession != null)
            {
                _dicomPrintSession.Dispose();
                _dicomPrintSession = null;
            }

            if (_selectPresentationsInformations != null)
            {
                foreach (var item in _selectPresentationsInformations)
                {
                    IImageSopProvider   imageSopProvider = item.Image as IImageSopProvider;
                    ILocalSopDataSource localSource      = null;
                    if (imageSopProvider != null)
                    {
                        localSource = imageSopProvider.ImageSop.DataSource as ILocalSopDataSource;
                    }

                    item.Dispose();
                    if (localSource != null)
                    {
                        localSource.Dispose();
                    }
                }

                _dicomPrinter = null;
            }
        }
Exemplo n.º 2
0
        private void OnTaskTerminated(object sender, BackgroundTaskTerminatedEventArgs e)
        {
            BackgroundTask updateTask = sender as BackgroundTask;

            if (updateTask != null)
            {
                updateTask.Terminated -= OnTaskTerminated;
                updateTask.Dispose();
            }
            _updateTask = null;
        }
Exemplo n.º 3
0
 private void TerminatedEventHandler(object sender, BackgroundTaskTerminatedEventArgs args)
 {
     if (args.Reason == BackgroundTaskTerminatedReason.Completed)
     {
         _continuationCode();
     }
     else
     {
         _errorHandler(args.Exception);
     }
 }
Exemplo n.º 4
0
        private void OnVolumeLoaderTaskTerminated(object sender, BackgroundTaskTerminatedEventArgs e)
        {
            BackgroundTask volumeLoaderTask = sender as BackgroundTask;

            if (volumeLoaderTask != null)
            {
                volumeLoaderTask.Terminated -= OnVolumeLoaderTaskTerminated;
                volumeLoaderTask.Dispose();
            }
            _volumeLoaderTask = null;
        }
Exemplo n.º 5
0
        private void OnVolumeLoaderTaskTerminated(object sender, BackgroundTaskTerminatedEventArgs e)
        {
            // TODO (CR Apr 2013): Since BeginLoad is only ever triggered from the UI thread (Draw), this won't be
            // a problem because the task's Terminated event will also be fired on the UI thread. If the task
            // were not created on the UI thread, though, this would have to be inside a lock (_syncLoaderLock).

            BackgroundTask volumeLoaderTask = sender as BackgroundTask;

            if (volumeLoaderTask != null)
            {
                volumeLoaderTask.Terminated -= OnVolumeLoaderTaskTerminated;
                volumeLoaderTask.Dispose();
            }

            _volumeLoaderTask = null;
        }
Exemplo n.º 6
0
            private void OnTerminated(object sender, BackgroundTaskTerminatedEventArgs e)
            {
                if (e.Reason == BackgroundTaskTerminatedReason.Exception)
                {
                    // not much we can do about it, except log it and return to blank state
                    Platform.Log(LogLevel.Error, e.Exception);
                    _owner.ChangeState(new CleanState(_owner));
                }
                else
                {
                    var shortlist = (IList <TItem>)e.Result;
                    if (shortlist == null)
                    {
                        // the request did not return a shortlist
                        // has the query been updated in the interim? if so, begin a new request immediately
                        if (_currentQuery != _query)
                        {
                            BeginRequest(_currentQuery);
                        }
                        else
                        {
                            // return to blank state
                            _owner.ChangeState(new CleanState(_owner));
                        }
                    }
                    else
                    {
                        // the request obtained a shortlist
                        // has the query been updated in the interim? if so, is it a refinement of the query that obtained the shortlist?
                        if (_currentQuery == _query || _owner.IsQueryRefinement(_currentQuery, _query))
                        {
                            if (_owner.AutoSort)
                            {
                                shortlist = CollectionUtils.Sort(shortlist, (x, y) => _owner.FormatItem(x).CompareTo(_owner.FormatItem(y)));
                            }

                            _owner.ChangeState(new ShortlistKnownState(_owner, _currentQuery, shortlist));
                        }
                        else
                        {
                            // the query was updated and is not a refinement, hence the shortlist is not valid
                            // begin a new request
                            BeginRequest(_currentQuery);
                        }
                    }
                }
            }
Exemplo n.º 7
0
        private void TerminatedHandler(object sender, BackgroundTaskTerminatedEventArgs e)
        {
            if (_autoClose && e.Reason != BackgroundTaskTerminatedReason.Exception)
            {
                this.ExitCode = ApplicationComponentExitCode.None;
                Host.Exit();
            }
            else
            {
                _marqueeSpeed = 0;
                _enableCancel = true;

                switch (e.Reason)
                {
                case BackgroundTaskTerminatedReason.Exception:
                    _exception    = e.Exception;
                    this.ExitCode = ApplicationComponentExitCode.Error;
                    Host.Exit();

                    break;

                case BackgroundTaskTerminatedReason.Completed:
                case BackgroundTaskTerminatedReason.Cancelled:
                default:
                    if (this.ProgressBarStyle == ProgressBarStyle.Marquee)
                    {
                        // Make the progress bar looks 'full' at completion
                        _progressBarStyle = ProgressBarStyle.Blocks;
                        _progressBar      = this.ProgressBarMaximum;
                    }
                    break;
                }

                SignalProgressTerminate();
            }
        }
Exemplo n.º 8
0
            public static bool Load(StudyFilterComponent component, IDesktopWindow desktopWindow, bool allowCancel, IEnumerable <string> paths, bool recursive)
            {
                BackgroundTaskTerminatedEventArgs evArgs = null;

                try
                {
                    using (var task = new BackgroundTask(LoadWorker, allowCancel, new State(component, paths, recursive)))
                    {
                        task.Terminated += (s, e) => evArgs = e;
                        ProgressDialog.Show(task, desktopWindow, true, ProgressBarStyle.Continuous);
                    }
                }
                catch (Exception ex)
                {
                    ExceptionHandler.Report(ex, desktopWindow);
                    return(false);
                }

                if (evArgs.Reason == BackgroundTaskTerminatedReason.Exception && evArgs.Exception != null)
                {
                    ExceptionHandler.Report(evArgs.Exception, desktopWindow);
                }
                return(evArgs.Reason == BackgroundTaskTerminatedReason.Completed);
            }
Exemplo n.º 9
0
 private void OnTaskTerminated(object sender, BackgroundTaskTerminatedEventArgs e)
 {
     EventsHelper.Fire(_progressUpdated, this, EventArgs.Empty);
 }
Exemplo n.º 10
0
 void WorkerTerminated(object sender, BackgroundTaskTerminatedEventArgs e)
 {
     EventsHelper.Fire(Terminated, this, null);
 }