Exemple #1
0
        public bool CheckConnection(string IP)
        {
            EventHandler <CheckConnectionCompletedEventArgs> callback = null;

            _systemServiceCient.Endpoint.Address = new System.ServiceModel.EndpointAddress(GenerateUri(IP));
            var tcs = new TaskCompletionSource <string>();

            callback = (sender, args) =>
            {
                RequestState state = PerformOperation(() => { tcs.SetResult(args.Result); });
                if (state != RequestState.Correct)
                {
                    tcs.SetResult("");
                }
                _systemServiceCient.CheckConnectionCompleted -= callback;
            };
            _systemServiceCient.CheckConnectionCompleted += callback;
            _systemServiceCient.CheckConnectionAsync();
            return(tcs.Task.Result.Equals(_testConnectionString));
        }