To run the demonstration:
- Start Visual Studio.
- Click
File > Open > Web Site, specify
C:\Users\Public\Documents\Micro Focus\prodname\Samples\MultiRunUnit, and click
Open.
- Build the solution.
- In Solution Explorer, right-click
service.asmx, click
Set As Start Page.
- Start the Web Service by clicking
Debug >
Start Without Debugging.
- Start a second Web Service by clicking
Debug >
Start Without Debugging.
- Click
AddTwoNumbers in both browsers.
- In one browser, enter 1 as the first operand and anything as the second operand.
- In the second browser, enter any operands (except 1) in each field.
To see the data being shared incorrectly, enter
False in the
UsingMultiRunUnits field, in both browsers. Click
Invoke in the browser where you entered 1, and then click
Invoke in the second browser. The first result to come back is correct, but the other result is the same as the first, which is
wrong. Here's what happens:
- The first instance creates a default run unit and sends its data to that run unit and waits.
- The second instance uses the default run unit and in doing so, it overwrites the data in the default run unit.
- The second instance adds the two numbers and returns the correct result.
- When the first instance finishes waiting, it uses the default run unit and adds the two numbers, which are now those from
the second instance. It returns the wrong result, the result for the second instance.
Now repeat the demonstration, but this time enter
True in the first field. The correct results are returned. Here's what happens:
- The first instance creates its own run unit and sends its data to that run unit and waits.
- The second instance creates another own run unit and sends its data to its own run unit.
- The second instance adds the two numbers and returns the correct result.
- When the first instance finishes waiting, it uses its own run unit. It adds the correct two numbers and returns the correct
result.