What is the proper way to dispose a CoreServiceClient
in SDL Web 8.5?
Some great Core Service posts from 2012 and 2013 instruct to check the state, and call Abort()
or Close()
. The Tridion-PowerShell-Modules project does something similar in Close-TridionCoreServiceClient.
if (_client.State == CommunicationState.Faulted)
{
_client.Abort();
}
else
{
_client.Close();
}
However, the Core Service client API has a CoreServiceClient.Dispose()
method, which calls ClientHelper.DisposeClient()
which does those checks already. Maybe this has changed over time, but I think the API handles this for us.