PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You are creating a Windows application by using the .NET Framework 3.5. You plan to create a form that might result in a time-consuming operation. You use the QueueUserWorkItem method and a Label control named lblResult. You need to update the users by using the lblResult control when the process has completed the
operation. Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
private void DoWork(object myParameter){
// thread work
this.Invoke(new MethodInvoker(ReportProgress));
}
private void ReportProgress()
{
this.lblResult.Text = “Finished Thread”;
}

B.
private void DoWork(object myParameter)
{
// thread work
this.lblResult.Text = “Finishe Thread”;
}

C.
private void DoWork(object myParameter)
{
// thread work
System.Threading.Monitor.Enter(this);
this.lblResult.Text = “Finished Thread”;
System.Threading.Monitor.Exit(this);
}

D.
private void DoWork(object myParameter)
{
// thread work
System.Threading.Monitor.TryEnter(this);
ReportProgress();
}
private void ReportProgress(){
this.lblResult.Text = “Finishe Thread”;
}


Leave a Reply