public long AddNewTask(SetupWorkMessage message)
 {
     long ID = this.OriginalTasks.addNewTask(message);
     this.CurrentTasks.AddTask(ID, message.TheDLL);
     this.ReduceList.CreateNewIdentity(ID);
     this.ReduceTasks.Add(ID, message.TheDLL);
     return ID;
 }
        public long addNewTask(SetupWorkMessage message)
        {
            long ID = 0;
            ReduceResult[] answer;

            ID = GetNewID();

            if (message.distributeOption == DistributerOptions.NONE)
            {
                Assembly assembly = Assembly.Load(message.TheDLL);
                var type = typeof(IDistributer);
                var types = assembly.GetTypes().Where(x => type.IsAssignableFrom(x)).ToArray();
                IDistributer instanceOfMyType = (IDistributer)Activator.CreateInstance(types[0]);
                answer = instanceOfMyType.Distribute(message.Data);
            }
            else
            {
                IDistributer distributer = DistributerFactory.CreateDistributer<string>(message.distributeOption);
                answer = distributer.Distribute(message.Data);
            }
            TaskIdentifier[] finished = new TaskIdentifier[answer.Length];
            int counter = 0;
            foreach (var item in answer)
            {
                finished[counter++] = new TaskIdentifier { Completed = false, DataObject = item };
            }

            Monitor.Enter(tasks);
            try
            {
                this.tasks.Add(ID, new TaskInfoOriginal(ID, finished, message.TheDLL, message.ReturnIP, message.Port));
            }
            finally
            {
                Monitor.Exit(tasks);
            }

            return ID;
        }
 public long AddNewTask(SetupWorkMessage message)
 {
     return this.TaskHandler.AddNewTask(message);
 }