public void EndSend(IAsyncResult result) { if (_async != null) { _async.AsyncWaitHandle.WaitOne(); } if (_assoc != null) { _assoc.Set(); } if (_client != null) { try { _client.Close(); } catch { } } _service = null; _client = null; _async = null; _assoc = null; if (_exception != null && !_abort) { throw _exception; } }
public new static IAsyncResult BeginOpen(string fileName, AsyncCallback callback, object state) { var df = new DicomStructuredReport(); // reset datasets df.FileMetaInfo.Clear(); df.Dataset.Clear(); df.File = new FileReference(fileName); FileByteSource source = new FileByteSource(df.File); EventAsyncResult result = new EventAsyncResult(callback, state); DicomFileReader reader = new DicomFileReader(); var datasetObserver = new DicomDatasetReaderObserver(df.Dataset); reader.BeginRead(source, new DicomDatasetReaderObserver(df.FileMetaInfo), datasetObserver, OnReadComplete, new Tuple <DicomFileReader, DicomStructuredReport, EventAsyncResult>(reader, df, result)); return(result); }
public new static IAsyncResult BeginOpen(string fileName, Encoding fallbackEncoding, AsyncCallback callback, object state) { var df = new DicomDirectory(); // reset datasets df.FileMetaInfo.Clear(); df.Dataset.Clear(); df.File = new FileReference(fileName); FileByteSource source = new FileByteSource(df.File); EventAsyncResult result = new EventAsyncResult(callback, state); DicomFileReader reader = new DicomFileReader(); var datasetObserver = new DicomDatasetReaderObserver(df.Dataset, fallbackEncoding); var dirObserver = new DicomDirectoryReaderObserver(df.Dataset); reader.BeginRead(source, new DicomDatasetReaderObserver(df.FileMetaInfo), new DicomReaderMultiObserver(datasetObserver, dirObserver), OnReadComplete, new Tuple <DicomFileReader, DicomDirectory, DicomDirectoryReaderObserver, EventAsyncResult>(reader, df, dirObserver, result)); return(result); }
public IAsyncResult BeginRead(IByteSource source, IDicomReaderObserver observer, DicomTag stop, AsyncCallback callback, object state) { _stop = stop; _observer = observer; _result = DicomReaderResult.Processing; _exception = null; _async = new EventAsyncResult(callback, state); ThreadPool.QueueUserWorkItem(ParseProc, source); return _async; }
public IAsyncResult BeginRead(IByteSource source, IDicomReaderObserver fileMetaInfo, IDicomReaderObserver dataset, AsyncCallback callback, object state) { _result = DicomReaderResult.Processing; _source = source; _fmiObserver = fileMetaInfo; _dataObserver = dataset; _async = new EventAsyncResult(callback, state); ParsePreamble(source, null); // ThreadPool? return _async; }
public IAsyncResult BeginRead(IByteSource source, IDicomReaderObserver fileMetaInfo, IDicomReaderObserver dataset, AsyncCallback callback, object state) { _result = DicomReaderResult.Processing; _source = source; _fmiObserver = fileMetaInfo; _dataObserver = dataset; _async = new EventAsyncResult(callback, state); ParsePreamble(source, null); // ThreadPool? return(_async); }
public IAsyncResult BeginRead(IByteSource source, IDicomReaderObserver observer, DicomTag stop, AsyncCallback callback, object state) { _stop = stop; _observer = observer; _result = DicomReaderResult.Processing; _exception = null; _async = new EventAsyncResult(callback, state); ThreadPool.QueueUserWorkItem(ParseProc, source); return(_async); }
public new static DicomStructuredReport EndOpen(IAsyncResult result) { result.AsyncWaitHandle.WaitOne(); EventAsyncResult eventResult = result as EventAsyncResult; var state = eventResult.InternalState as Tuple <DicomStructuredReport, Exception>; if (state.Item2 != null) { throw new DicomFileException(state.Item1, state.Item2.Message, state.Item2); } return(state.Item1); }
public void Abort() { try { _abort = true; _client.Close(); } catch { } finally { _client = null; try { _async.Set(); } catch { } _async = null; } }
public IAsyncResult BeginSend(Stream stream, string callingAe, string calledAe, AsyncCallback callback, object state) { var assoc = new DicomAssociation(callingAe, calledAe); assoc.MaxAsyncOpsInvoked = _asyncInvoked; assoc.MaxAsyncOpsPerformed = _asyncPerformed; foreach (var request in _requests) { assoc.PresentationContexts.AddFromRequest(request); } _service = new DicomServiceUser(this, stream, assoc, Logger); _async = new EventAsyncResult(callback, state); return(_async); }
public IAsyncResult BeginWrite(IByteTarget target, DicomFileMetaInformation fileMetaInfo, DicomDataset dataset, AsyncCallback callback, object state) { _target = target; _fileMetaInfo = fileMetaInfo; _dataset = dataset; _async = new EventAsyncResult(callback, state); byte[] preamble = new byte[132]; preamble[128] = (byte)'D'; preamble[129] = (byte)'I'; preamble[130] = (byte)'C'; preamble[131] = (byte)'M'; _target.Write(preamble, 0, 132, OnCompletePreamble, null); return _async; }
public IAsyncResult BeginWrite(IByteTarget target, DicomFileMetaInformation fileMetaInfo, DicomDataset dataset, AsyncCallback callback, object state) { _target = target; _fileMetaInfo = fileMetaInfo; _dataset = dataset; _async = new EventAsyncResult(callback, state); byte[] preamble = new byte[132]; preamble[128] = (byte)'D'; preamble[129] = (byte)'I'; preamble[130] = (byte)'C'; preamble[131] = (byte)'M'; _target.Write(preamble, 0, 132, OnCompletePreamble, null); return(_async); }
public IAsyncResult BeginSend(Stream stream, string callingAe, string calledAe, AsyncCallback callback, object state) { var assoc = new DicomAssociation(callingAe, calledAe); assoc.MaxAsyncOpsInvoked = _asyncInvoked; assoc.MaxAsyncOpsPerformed = _asyncPerformed; foreach (var request in _requests) { assoc.PresentationContexts.AddFromRequest(request); } foreach (var context in _contexts) { assoc.PresentationContexts.Add(context.AbstractSyntax, context.GetTransferSyntaxes().ToArray()); } _service = new DicomServiceUser(this, stream, assoc, Logger); _assoc = new ManualResetEventSlim(false); _async = new EventAsyncResult(callback, state); return(_async); }
public IAsyncResult BeginSend(Stream stream, string callingAe, string calledAe, AsyncCallback callback, object state) { var assoc = new DicomAssociation(callingAe, calledAe); assoc.MaxAsyncOpsInvoked = _asyncInvoked; assoc.MaxAsyncOpsPerformed = _asyncPerformed; foreach (var request in _requests) { assoc.PresentationContexts.AddFromRequest(request); } foreach (var context in _contexts) { assoc.PresentationContexts.Add(context.AbstractSyntax, context.GetTransferSyntaxes().ToArray()); } _service = new DicomServiceUser(this, stream, assoc, Logger); //zssure:2015-04-14,try to conform whether AddRequest and Send uses the same one client LogManager.Default.GetLogger("Dicom.Network").Info("zssure debug at 20150414,the DicomServiceUser object is {0},HashCode{1}", _service.ToString(), _service.GetHashCode()); //zssure:2015-04-14,end _assoc = new ManualResetEventSlim(false); _async = new EventAsyncResult(callback, state); return(_async); }
public void EndSend(IAsyncResult result) { _async.AsyncWaitHandle.WaitOne(); if (_client != null) { try { _client.Close(); } catch { } } _service = null; _async = null; if (_exception != null) throw _exception; }
public void EndSend(IAsyncResult result) { if (_async != null) _async.AsyncWaitHandle.WaitOne(); if (_assoc != null) _assoc.Set(); if (_client != null) { try { _client.Close(); } catch { } } _service = null; _client = null; _async = null; _assoc = null; if (_exception != null && !_abort) throw _exception; }
public IAsyncResult BeginSend( Stream stream, string callingAe, string calledAe, AsyncCallback callback, object state) { var assoc = new DicomAssociation(callingAe, calledAe); assoc.MaxAsyncOpsInvoked = _asyncInvoked; assoc.MaxAsyncOpsPerformed = _asyncPerformed; foreach (var request in _requests) assoc.PresentationContexts.AddFromRequest(request); foreach (var context in _contexts) assoc.PresentationContexts.Add(context.AbstractSyntax, context.GetTransferSyntaxes().ToArray()); _service = new DicomServiceUser(this, stream, assoc, Logger); _assoc = new ManualResetEventSlim(false); _async = new EventAsyncResult(callback, state); return _async; }
public new static IAsyncResult BeginOpen(string fileName, AsyncCallback callback, object state) { var df = new DicomDirectory(); // reset datasets df.FileMetaInfo.Clear(); df.Dataset.Clear(); df.File = new FileReference(fileName); FileByteSource source = new FileByteSource(df.File); EventAsyncResult result = new EventAsyncResult(callback, state); DicomFileReader reader = new DicomFileReader(); var datasetObserver = new DicomDatasetReaderObserver(df.Dataset); var dirObserver = new DicomDirectoryReaderObserver(df.Dataset); reader.BeginRead(source, new DicomDatasetReaderObserver(df.FileMetaInfo), new DicomReaderMultiObserver(datasetObserver, dirObserver), OnReadComplete, new Tuple<DicomFileReader, DicomDirectory, DicomDirectoryReaderObserver, EventAsyncResult>(reader, df, dirObserver, result)); return result; }
public IAsyncResult BeginSend(Stream stream, string callingAe, string calledAe, AsyncCallback callback, object state) { var assoc = new DicomAssociation(callingAe, calledAe); assoc.MaxAsyncOpsInvoked = _asyncInvoked; assoc.MaxAsyncOpsPerformed = _asyncPerformed; foreach (var request in _requests) assoc.PresentationContexts.AddFromRequest(request); _service = new DicomServiceUser(this, stream, assoc, Logger); _async = new EventAsyncResult(callback, state); return _async; }
public IAsyncResult BeginSend(Stream stream, string callingAe, string calledAe, AsyncCallback callback, object state) { var assoc = new DicomAssociation(callingAe, calledAe); assoc.MaxAsyncOpsInvoked = _asyncInvoked; assoc.MaxAsyncOpsPerformed = _asyncPerformed; foreach (var request in _requests) assoc.PresentationContexts.AddFromRequest(request); foreach (var context in _contexts) assoc.PresentationContexts.Add(context.AbstractSyntax, context.GetTransferSyntaxes().ToArray()); _service = new DicomServiceUser(this, stream, assoc, Logger); //zssure:2015-04-14,try to conform whether AddRequest and Send uses the same one client LogManager.Default.GetLogger("Dicom.Network").Info("zssure debug at 20150414,the DicomServiceUser object is {0},HashCode{1}", _service.ToString(),_service.GetHashCode()); //zssure:2015-04-14,end _assoc = new ManualResetEventSlim(false); _async = new EventAsyncResult(callback, state); return _async; }