You are developing an application to perform mathematical calculations.

You are developing an application to perform mathematical calculations. You develop a class
named CalculationValues. You write a procedure named PerformCalculation that operates on an
instance of the class.
You need to ensure that the user interface of the application continues to respond while
calculations are being performed. You need to write a code segment that calls the
PerformCalculation procedure to achieve this goal.
Which code segment should you use?

A. public ref class CalculationValues {}; public ref class Calculator {
    public :
    void PerformCalculation() {} }; public ref class ThreadTest{
    private :
    void DoWork (){
   CalculationValues^ myValues = gcnew CalculationValues();
    Calculator^ calc = gcnew Calculator();
    Thread^ newThread = gcnew Thread(
    gcnew ThreadStart(calc, &Calculator::PerformCalculation));
    newThread->Start(myValues);
    }};
B. public ref class Calculation Values {}; public ref class Calculator {
    public :void PerformCalculation() {}}; public ref class ThreadTest{
    private :
    void DoWork (){
    CalculationValues^ myValues = gcnew CalculationValues();
    Calculator^ calc = gcnew Calculator();
    ThreadStart^ delStart = gcnew
    ThreadStart(calc, &Calculator::PerformCalculation);
    Thread^ newThread = gcnew Thread(delStart);
    if (newThread->IsAlive) {
    newThread->Start(myValues);
    }
    }};
C. public ref class Calculation Values {}; public ref class Calculator {
    public :
    void PerformCalculation(CalculationValues^ values) {} }; public ref class ThreadTest{
    private :
    void DoWork (){
    CalculationValues^ myValues = gcnew CalculationValues();
    Calculator^ calc = gcnew Calculator();
    Application::DoEvents();
    calc->PerformCalculation(myValues);
    Application::DoEvents();
    }};
D. public ref class Calculation Values {}; public ref class Calculator {
    public :
    void PerformCalculation(Object^ values) {} }; public ref class ThreadTest{
    private :
    void DoWork (){
    CalculationValues^ myValues = gcnew CalculationValues();
    Calculator^ calc = gcnew Calculator();
    Thread^ newThread = gcnew Thread(
    gcnew ParameterizedThreadStart(calc,
    &Calculator::PerformCalculation));
    newThread->Start(myValues);
    }};

Answer: D

No comments:

Post a Comment