private void AssociationAbortReceived(byte[] pdu) { Dump("<< A-ABORT", pdu); //#if DEBUG // if (number != 0) Console.WriteLine("association {0,4} aborted", number); //#endif // parse response MemoryStream memory = new MemoryStream(pdu, 0, pdu.Length); AssociateAbortPdu response = new AssociateAbortPdu(); response.Read(memory); // the exception should be thrown on the foreground service thread abortexception = new AssociationAbortedException(response.Source, response.Reason, String.Format("Association aborted by provider ({0}).", response.Reason)); State = State.Aborted; // the association is aborted, free any services awaiting respsonses foreach (ServiceClass service in services) { service.completeEvent.Set(); } }
/// <summary> /// Aborts the association. /// </summary> internal void Abort(AbortSource source, AbortReason reason) { AssertValid(); if (!IsOpen()) { throw new Exception("Association not open."); } // the exception should be thrown on the foreground service thread abortexception = new AssociationAbortedException(source, reason, "Association aborted at the client's request."); State = State.Aborted; // the association is aborted, free any services awaiting respsonses foreach (ServiceClass service in services) { service.completeEvent.Set(); } AssociateAbortPdu abort = new AssociateAbortPdu(); abort.Source = source; abort.reason = reason; Send("A-ABORT", abort); }