You need to ensure that each value is appended to the Value property in the order that the Modify methods are invoked

You have the following class (line numbers are included for reference only):

ServiceProxy is a proxy for a web service. Calls to the Update method can take up to five
seconds. The Test class is the only class the uses Class1.
You run the Execute method three times, and you receive the following results:
213
312
231
You need to ensure that each value is appended to the Value property in the order that the
Modify methods are invoked.
What should you do?

You have the following class (line numbers are included for reference only):

ServiceProxy is a proxy for a web service. Calls to the Update method can take up to five
seconds. The Test class is the only class the uses Class1.
You run the Execute method three times, and you receive the following results:
213
312
231
You need to ensure that each value is appended to the Value property in the order that the
Modify methods are invoked.
What should you do?

A.
Option A

B.
Option B

C.
Option C

D.
Option D



Leave a Reply 5

Your email address will not be published. Required fields are marked *


janko

janko

Why B? The third invoke can still lock this object first. Lock does not insure order of locking only that invoking of proxy.Update will be called one by one and not parallel.

anii

anii

If I can understand correctly, we can’t use Monitor.Enter option because then we would have to write additional code like Monitor.Exit and put it all in try..finally block. The code is much more complex than just writing Monitor.Enter in a line.
Source: https://msdn.microsoft.com/en-us/library/de0542zz(v=vs.110).aspx

So, I agree: B is the answer.

Please correct me if I’m mistaken in any way.