public PalindromChecker(Object operand, Object resultAction)
 {
     ResultAction = resultAction as ResultBase;
     _input = new SingleOperandInput() { Operand = operand };
 }
        private void queueButton_Click(object sender, EventArgs e)
        {
            Int32 queueingThreads;
            Int32 tasksPerThread;

            // Sanity checks.
            if (!Int32.TryParse(queueThreadsTextBox.Text, out queueingThreads))
            {
                throw new ArgumentException("Expected a number as number of queuing worker threads.");
            }
            if (queueingThreads < 1)
            {
                throw new ArgumentException("Expected at least 1 queuing worker threads.");
            }
            if (!Int32.TryParse(tasksPerThreadTextBox.Text, out tasksPerThread))
            {
                throw new ArgumentException("Expected a number as the number of tasks each queuing thread will enqueue.");
            }
            if (tasksPerThread < 1)
            {
                throw new ArgumentException("Expected at least 1 tasks to be enqueued by each thread.");
            }

            // Create instances of the task and the result-action.
            Object taskInstance = null;
            Object resultInstance = null;

            TaskObject taskObj = _taskDescriptionToObject[tasksComboBox.Text];

            // Instantiate the concrete result class
            if (!taskObj.RequiresInput)
            {
                resultInstance = Activator.CreateInstance(taskObj.ConcreteActionAndResult.Value);
            }

            if (taskObj.OperandsRequired == 1)
            {
                if (taskObj.RequiresInput)
                {
                    SingleOperandInput soi = new SingleOperandInput() { Operand = operand1TextBox.Text };
                    resultInstance = Activator.CreateInstance(taskObj.ConcreteActionAndResult.Value, new Object[] { soi });
                }
                taskInstance = Activator.CreateInstance(taskObj.ConcreteActionAndResult.Key, new Object[] { operand1TextBox.Text, resultInstance });
            }
            else if (taskObj.OperandsRequired == 2)
            {
                if (taskObj.RequiresInput)
                {
                    TwoOperandsInput toi = new TwoOperandsInput() { Operand1 = operand1TextBox.Text, Operand2 = operand2TextBox.Text };
                    resultInstance = Activator.CreateInstance(taskObj.ConcreteActionAndResult.Value, new Object[] { operand1TextBox.Text, operand2TextBox.Text });
                }
                taskInstance = Activator.CreateInstance(taskObj.ConcreteActionAndResult.Key, new Object[] { operand1TextBox.Text, operand2TextBox.Text, resultInstance });
            }
            else
            {
                throw new NotImplementedException("Not supporting more than 2 operands.");
            }

            ((ITask)taskInstance).ResultAction.Changed += NewResult;
            // Enqueue the task the amount of times specified, using the amount of threads specified.
            EnqueueConcurrent(queueingThreads, tasksPerThread, taskInstance);
        }