public ClientServerConnection(IPAddress localIp, IPAddress serverIp, int serverPort) : base(localIp, serverIp, serverPort)
 {
     Logging.WriteLog("Connecting to server on " + ServerUri);
     DistributedTaskLibraryHost = RemoteConnection.CreateHost(UriTemplates.CreateLibrariesUri(LocalUri), typeof(IDistributedTaskLibraryService), typeof(DistributedTaskLibraryService));
     DistributedTaskLibraryHost.Open();
     try
     {
         var registration = RemoteConnection.CreateProxy <IClientRegistrationService>(UriTemplates.CreateClientRegistrationUri(ServerUri));
         registration.Connect(LocalUri);
     }
     catch (Exception e)
     {
         DistributedTaskLibraryHost.Close();
         Dispose();
         throw new NoServerConnectionException();
     }
     ConnectionControl = new ConnectionControl(this, ServerUri);
 }
        public WorkerServerConnection(IPAddress localIp, IPAddress serverIp, int port) : base(localIp, serverIp, port)
        {
            Logging.WriteLog("Connecting to server on " + ServerUri);
            PerformanceService     = new WorkerPerformanceService();
            PerformanceServiceHost = RemoteConnection.CreateHost(UriTemplates.CreatePerformanceUri(LocalUri), typeof(IWorkerPerformanceService), PerformanceService);
            PerformanceServiceHost.Open();
            TasksService     = new WorkerTaskService(LocalUri);
            TasksServiceHost = RemoteConnection.CreateHost(UriTemplates.CreateTasksUri(LocalUri), typeof(IWorkerTaskService), TasksService);
            TasksServiceHost.Open();
            var registation = RemoteConnection.CreateProxy <IWorkerRegistrationService>(UriTemplates.CreateWorkerRegistrationUri(ServerUri));

            try
            {
                registation.Connect(LocalUri);
            }
            catch (Exception e)
            {
                TasksServiceHost.Close();
                PerformanceServiceHost.Close();
                Dispose();
                throw new NoServerConnectionException();
            }
            ConnectionControl = new ConnectionControl(this, ServerUri);
        }