コード例 #1
0
        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;
        }
コード例 #2
0
 public TaskInfoSetup(long ID, TaskIdentifier[] task, byte[] WorkDll, string ReturnIP, int ReturnPort)
     : base(ID, WorkDll, ReturnIP, ReturnPort)
 {
     this.task = task;
 }