Example #1
0
 /// <summary>
 /// Closes the connection or abort.
 /// </summary>
 /// <param name="serviceClient">The service client.</param>
 public static void CloseConnectionOrAbort(this ICommunicationObject serviceClient)
 {
     serviceClient.CloseConnection();
     if (serviceClient == null)
     {
         return;
     }
     if ((serviceClient.State != CommunicationState.Closed) || (serviceClient.State != CommunicationState.Closing))
     {
         serviceClient.Abort();
     }
 }
        /// <summary>
        /// Closes the connection or abort.
        /// </summary>
        /// <param name="serviceClient">The service client.</param>
        /// <param name="waitInMilliseconds">The wait in milliseconds.</param>
        public static void CloseConnectionOrAbort(this ICommunicationObject serviceClient, int waitInMilliseconds = 500)
        {
            if (serviceClient == null)
            {
                return;
            }
            serviceClient.CloseConnection();

            Thread.Sleep(waitInMilliseconds);

            if ((serviceClient.State != CommunicationState.Closed) &&
                (serviceClient.State != CommunicationState.Closing))
            {
                serviceClient.Abort();
            }
        }