예제 #1
0
        /// <summary>
        /// Tries to connect to the server and returns a value indicating whether the demanded object exists
        /// </summary>
        /// <returns>a value indicating whether the remote object exists</returns>
        private bool CheckConnection()
        {
            lock (client.Sync)
            {
                if (!connected)
                {
                    if (client.ValidateConnection())
                    {
                        var result = client.CheckRemoteObjectAvailability(remoteObjectName);
                        if (result.Available)
                        {
                            connected = true;
                            if (initial)
                            {
                                client.SubscribeEvent(remoteObjectName,
                                                      ParallellResources
                                                      .ParallelMethod_PackageProcessed,
                                                      packageFinishedHandler);
                                initial = false;
                            }
                        }
                        else
                        {
                            LogEnvironment.LogDebugEvent(result.Message, LogSeverity.Warning);
                        }
                    }
                }

                return(connected);
            }
        }