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)); }
public IAsyncResult BeginWalk(IDicomDatasetWalker walker, AsyncCallback callback, object state) { _walker = walker; _exception = null; _async = new EventAsyncResult(callback, state); ThreadPool.QueueUserWorkItem(Walk, null); return _async; }
public IAsyncResult BeginWalk(IDicomDatasetWalker walker, AsyncCallback callback, object state) { _walker = walker; _exception = null; _async = new EventAsyncResult(callback, state); ThreadPool.QueueUserWorkItem(Walk, null); return(_async); }
public void EndSave(IAsyncResult result) { EventAsyncResult async = result as EventAsyncResult; result.AsyncWaitHandle.WaitOne(); if (async.InternalState != null) { throw async.InternalState as Exception; } }
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)); }
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); }
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); }
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; }
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); }
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)); }