private void DisposeOf(DataStructure objectId)
{
try
{
RemoveInfo command = new RemoveInfo();
command.ObjectId = objectId;
if(asyncClose)
{
Tracer.Info("Asynchronously disposing of Connection.");
if(connected.Value)
{
transport.Oneway(command);
}
Tracer.Info("Oneway command sent to broker.");
}
else
{
// Ensure that the object is disposed to avoid potential race-conditions
// of trying to re-create the same object in the broker faster than
// the broker can dispose of the object. Allow up to 5 seconds to process.
Tracer.Info("Synchronously disposing of Connection.");
SyncRequest(command, TimeSpan.FromSeconds(5));
Tracer.Info("Synchronously closed Connection.");
}
}
catch // (BrokerException)
{
// Ignore exceptions while shutting down.
}
}