コード例 #1
0
        public void BeginSave(string fileName, AsyncCallback callback, object state)
        {
            if (Format == DicomFileFormat.ACRNEMA1 || Format == DicomFileFormat.ACRNEMA2)
            {
                throw new DicomFileException(this, "Unable to save ACR-NEMA file");
            }

            if (Format == DicomFileFormat.DICOM3NoFileMetaInfo)
            {
                // create file meta information from dataset
                FileMetaInfo = new DicomFileMetaInformation(Dataset);
            }

            File = new FileReference(fileName);
            File.Delete();

            OnSave();

            FileByteTarget target = new FileByteTarget(File);

            EventAsyncResult result = new EventAsyncResult(callback, state);

            DicomFileWriter writer = new DicomFileWriter(DicomWriteOptions.Default);

            writer.BeginWrite(target, FileMetaInfo, Dataset, OnWriteComplete, new Tuple <DicomFileWriter, EventAsyncResult>(writer, result));
        }
コード例 #2
0
ファイル: DicomDatasetWalker.cs プロジェクト: GMZ/fo-dicom
 public IAsyncResult BeginWalk(IDicomDatasetWalker walker, AsyncCallback callback, object state)
 {
     _walker = walker;
     _exception = null;
     _async = new EventAsyncResult(callback, state);
     ThreadPool.QueueUserWorkItem(Walk, null);
     return _async;
 }
コード例 #3
0
 public IAsyncResult BeginWalk(IDicomDatasetWalker walker, AsyncCallback callback, object state)
 {
     _walker    = walker;
     _exception = null;
     _async     = new EventAsyncResult(callback, state);
     ThreadPool.QueueUserWorkItem(Walk, null);
     return(_async);
 }
コード例 #4
0
ファイル: DicomFile.cs プロジェクト: sczx888/fo-dicom
        public void EndSave(IAsyncResult result)
        {
            EventAsyncResult async = result as EventAsyncResult;

            result.AsyncWaitHandle.WaitOne();

            if (async.InternalState != null)
            {
                throw async.InternalState as Exception;
            }
        }
コード例 #5
0
ファイル: DicomFile.cs プロジェクト: sczx888/fo-dicom
        public void BeginSave(string fileName, AsyncCallback callback, object state)
        {
            File = new FileReference(fileName);
            File.Delete();

            FileByteTarget target = new FileByteTarget(File);

            EventAsyncResult async = new EventAsyncResult(callback, state);

            DicomFileWriter writer = new DicomFileWriter(DicomWriteOptions.Default);

            writer.BeginWrite(target, FileMetaInfo, Dataset, OnWriteComplete, new Tuple <DicomFileWriter, EventAsyncResult>(writer, async));
        }
コード例 #6
0
ファイル: DicomFile.cs プロジェクト: sczx888/fo-dicom
        public static DicomFile EndOpen(IAsyncResult result)
        {
            result.AsyncWaitHandle.WaitOne();

            EventAsyncResult async = result as EventAsyncResult;
            var state = async.InternalState as Tuple <DicomFile, Exception>;

            if (state.Item2 != null)
            {
                throw state.Item2;
            }

            return(state.Item1);
        }
コード例 #7
0
        public static DicomFile EndOpen(IAsyncResult result)
        {
            result.AsyncWaitHandle.WaitOne();

            EventAsyncResult eventResult = result as EventAsyncResult;
            var state = eventResult.InternalState as Tuple <DicomFile, Exception>;

            if (state.Item2 != null)
            {
                throw new DicomFileException(state.Item1, state.Item2.Message, state.Item2);
            }

            return(state.Item1);
        }
コード例 #8
0
ファイル: DicomFile.cs プロジェクト: vdrm/fo-dicom
        public static IAsyncResult BeginOpen(string fileName, AsyncCallback callback, object state)
        {
            DicomFile df = new DicomFile();
            df.File = new FileReference(fileName);

            FileByteSource source = new FileByteSource(df.File);

            EventAsyncResult result = new EventAsyncResult(callback, state);

            DicomFileReader reader = new DicomFileReader();
            reader.BeginRead(source,
                new DicomDatasetReaderObserver(df.FileMetaInfo),
                new DicomDatasetReaderObserver(df.Dataset),
                OnReadComplete, new Tuple<DicomFileReader, DicomFile, EventAsyncResult>(reader, df, result));

            return result;
        }
コード例 #9
0
ファイル: DicomFile.cs プロジェクト: sczx888/fo-dicom
        public static IAsyncResult BeginOpen(string fileName, AsyncCallback callback, object state)
        {
            DicomFile df = new DicomFile();

            df.File = new FileReference(fileName);
            FileByteSource source = new FileByteSource(df.File);

            EventAsyncResult async = new EventAsyncResult(callback, state);

            DicomFileReader reader = new DicomFileReader();

            reader.BeginRead(source,
                             new DicomDatasetReaderObserver(df.FileMetaInfo),
                             new DicomDatasetReaderObserver(df.Dataset),
                             OnReadComplete, new Tuple <DicomFileReader, DicomFile, EventAsyncResult>(reader, df, async));

            return(async);
        }
コード例 #10
0
ファイル: DicomFile.cs プロジェクト: dremerdt/fo-dicom
		public void BeginSave(string fileName, AsyncCallback callback, object state) {
			if (Format == DicomFileFormat.ACRNEMA1 || Format == DicomFileFormat.ACRNEMA2)
				throw new DicomFileException(this, "Unable to save ACR-NEMA file");

			if (Format == DicomFileFormat.DICOM3NoFileMetaInfo) {
				// create file meta information from dataset
				FileMetaInfo = new DicomFileMetaInformation(Dataset);
			}

			File = new FileReference(fileName);
			File.Delete();

			OnSave();

			FileByteTarget target = new FileByteTarget(File);

			EventAsyncResult result = new EventAsyncResult(callback, state);

			DicomFileWriter writer = new DicomFileWriter(DicomWriteOptions.Default);
			writer.BeginWrite(target, FileMetaInfo, Dataset, OnWriteComplete, new Tuple<DicomFileWriter, EventAsyncResult>(writer, result));
		}