Beispiel #1
0
        private void ProcessStudyFolder(string folder)
        {
            try
            {
                string studyInstanceUid = Path.GetFileName(folder);
                var    location         = new StudyLocation(studyInstanceUid);

                var reprocessStudyFolder = new ReprocessStudyFolder(location);

                _threadPool.Enqueue(reprocessStudyFolder, delegate(ReprocessStudyFolder r)
                {
                    var del = new ThreadPoolStopProxy(r);
                    _threadPool.StartStopStateChangedEvent += del.ProxyDelegate;
                    // TODO (CR Jun 2012): Should check the thread pool state right after
                    // subscribing; otherwise, the folder will process to completion, rather than canceling.

                    r.Process();

                    lock (_syncLock)
                        EventsHelper.Fire(
                            r.Failed ? _studyFailedEvent
                                                                                   : _studyFolderProcessedEvent,
                            this,
                            new StudyEventArgs
                        {
                            StudyInstanceUid = r.Location.Study.StudyInstanceUid,
                            Message          = r.FailureMessage
                        });

                    _threadPool.StartStopStateChangedEvent -= del.ProxyDelegate;
                });
            }
            catch (Exception x)
            {
                // TODO (CR Jun 2012): Shouldn't this cause the work item to fail?
                Platform.Log(LogLevel.Error, x, "Unexpected exception reindexing folder: {0}", folder);
            }
        }
Beispiel #2
0
 public ThreadPoolStopProxy(ReprocessStudyFolder r)
 {
     _r = r;
 }