Opc.Ua.Client.Session.EndBrowse C# (CSharp) Method

EndBrowse() public method

Finishes an asynchronous invocation of the Browse service.
public EndBrowse ( IAsyncResult result, byte &continuationPoint, ReferenceDescriptionCollection &references ) : ResponseHeader
result IAsyncResult The result.
continuationPoint byte The continuation point.
references ReferenceDescriptionCollection The list of node references.
return ResponseHeader
        public ResponseHeader EndBrowse(
            IAsyncResult result,
            out byte[] continuationPoint,
            out ReferenceDescriptionCollection references)
        {
            BrowseResultCollection results;
            DiagnosticInfoCollection diagnosticInfos;

            ResponseHeader responseHeader = EndBrowse(
                result,
                out results,
                out diagnosticInfos);

            if (results == null || results.Count != 1)
            {
                throw new ServiceResultException(StatusCodes.BadUnknownResponse);
            }

            if (StatusCode.IsBad(results[0].StatusCode))
            {
                throw new ServiceResultException(new ServiceResult(results[0].StatusCode, 0, diagnosticInfos, responseHeader.StringTable));
            }

            continuationPoint = results[0].ContinuationPoint;
            references = results[0].References;

            return responseHeader;
        }
        #endregion

Usage Example

 public static Task <ReferenceDescriptionCollection> BrowseAsync(this Session session, NodeId nodeToBrowse)
 {
     return(Task.Factory.FromAsync(
                (callback, state) =>
                session.BeginBrowse(
                    null,
                    null,
                    nodeToBrowse,
                    0,
                    BrowseDirection.Forward,
                    ReferenceTypeIds.Organizes,
                    false,
                    (uint)NodeClass.Object,
                    callback,
                    state),
                result =>
     {
         session.EndBrowse(result, out var continuationPoint, out var references);
         return references;
     },