Opc.Ua.WcfChannelBase.SendRequestAsyncResult.WaitForComplete C# (CSharp) Method

WaitForComplete() public static method

Checks for a valid IAsyncResult object and waits for the operation to complete.
public static WaitForComplete ( IAsyncResult ar ) : IServiceResponse
ar IAsyncResult The IAsyncResult object for the operation.
return IServiceResponse
            public static new IServiceResponse WaitForComplete(IAsyncResult ar)
            {
                SendRequestAsyncResult result = ar as SendRequestAsyncResult;

                if (result == null)
                {
                    throw new ArgumentException("End called with an invalid IAsyncResult object.", "ar");
                }

                if (result.m_response == null && result.m_error == null)
                {
                    if (!result.WaitForComplete())
                    {
                        throw new TimeoutException();
                    }
                }

                if (result.m_error != null)
                {
                    throw new ServiceResultException(result.m_error, StatusCodes.BadInternalError);
                }

                return result.m_response;
            }