コード例 #1
0
        private void OnGetEndpointsComplete(IAsyncResult result)
        {
            GetEndpointsData data = result.AsyncState as GetEndpointsData;

            try
            {
                EndpointDescriptionCollection endpoints = null;
                data.DiscoveryClient.EndGetEndpoints(result, out endpoints);

                data.Endpoints = endpoints;
                data.OperationCompleted();
            }
            catch (Exception e)
            {
                data.Exception = e;
                data.OperationCompleted();
            }
        }
コード例 #2
0
        public List <EndpointDescription> EndGetEndpoints(IAsyncResult result)
        {
            GetEndpointsData data = result as GetEndpointsData;

            if (data == null)
            {
                throw new ArgumentException("Did not pass the correct IAsyncResult to end method.", "success");
            }

            try
            {
                if (!data.WaitForComplete())
                {
                    throw new TimeoutException();
                }

                return(data.Endpoints);
            }
            finally
            {
                data.DiscoveryClient.Close();
            }
        }
コード例 #3
0
        public IAsyncResult BeginGetEndpoints(
            string endpointUrl,
            string endpointTransportProfileUri,
            AsyncCallback callback,
            object callbackData)
        {
            DiscoveryClient client = CreateClient(endpointUrl, endpointTransportProfileUri);

            GetEndpointsData data = new GetEndpointsData(callback, callbackData, client.OperationTimeout)
            {
                DiscoveryClient = client
            };

            data.InnerResult = client.BeginGetEndpoints(
                null,
                endpointUrl,
                new StringCollection(PreferredLocales),
                null,
                OnGetEndpointsComplete,
                data);

            return(data);
        }
コード例 #4
0
        private void OnGetEndpointsComplete(IAsyncResult result)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new AsyncCallback(OnGetEndpointsComplete), result);
                return;
            }

            GetEndpointsData data = (GetEndpointsData)result.AsyncState;

            try
            {
                List <EndpointDescription> endpoints = data.Lds.EndGetEndpoints(result);

                if (DiscoveryTreeView.SelectedNode == data.Parent)
                {
                    ShowEndpointDescriptions(endpoints);
                }
            }
            catch (Exception e)
            {
                Opc.Ua.Client.Controls.ExceptionDlg.Show(Text, e);
            }
        }