Opc.Ua.EndpointBase.ProcessRequestAsyncResult.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, bool throwOnError ) : IServiceResponse
ar IAsyncResult The IAsyncResult object for the operation.
throwOnError bool if set to true an exception is thrown if an error occurred.
return IServiceResponse
            public static IServiceResponse WaitForComplete(IAsyncResult ar, bool throwOnError)
            {
                ProcessRequestAsyncResult result = ar as ProcessRequestAsyncResult;

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

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

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

                return result.m_response;
            }