public DistributedResource Execute(Uri clientUri, int taskId, DistributedResource resource)
        {
            Logging.WriteLog("Request for executing task on single resource was received");
            DistributedResource result = null;
            int trycount = TryCount;

            do
            {
                WorkerInfo workerInfo = null;
                lock (Server.Workers)
                {
                    List <int> performance = Server.Workers.Select <WorkerInfo, int>(worker => worker.GetPerformance(clientUri)).ToList();
                    if (performance.Count != 0)
                    {
                        workerInfo = Server.Workers[performance.FindIndex(perform => perform == performance.Max())];
                        var service = RemoteConnection.CreateProxy <IWorkerTaskService>(UriTemplates.CreateTasksUri(workerInfo.WorkerUri));
                        try
                        {
                            result = service.ExecuteTask(workerInfo.Tasks[taskId], resource);
                            trycount--;
                        }
                        catch
                        { }
                    }
                }
            }while (result == null && Server.Workers.Count != 0 && trycount > 0);
            return(result);
        }
        public void Connect(Uri workerUri)
        {
            var workerInfo = new WorkerInfo(workerUri);
            var service    = RemoteConnection.CreateProxy <IWorkerTaskService>(UriTemplates.CreateTasksUri(workerUri));

            foreach (Uri client in Server.Clients)
            {
                workerInfo.Connections.Add(new ConnectionInfo(client, service.CheckConnection(client)));
            }
            for (int i = 0; i < Server.TaskLibraryManager.Tasks.Count; i++)
            {
                workerInfo.Tasks.Add(i, service.CreateTask(Server.TaskLibraryManager.Tasks[i].CreateDistributedTaskLibrary(Server.ServerUri)));
            }
            lock (Server.Workers)
            {
                if (Server.Workers.Count == 0)
                {
                    Server.OpenClientConnection();
                }
                Server.Workers.Add(workerInfo);
            }
            Server.ConnectionControl.AddWorkerConnection(workerUri);
            Logging.WriteLog("Worker on " + workerUri + " connected");
        }