7digital/SevenDigital.Api.Wrapper — pull request #34 by AnthonySteele (2012-11-13 09:58:05+00:00)
Title: Api copy idea demo

Here is another pull request that should not be merged but demonstrates an approach to making the API thread-safe.

The advantages of this idea are that there are very few lines of code added, and that existing code doesn't need to change at all.

The disadvantage is that new parallel code has to call a "NewInstance()" method on the IFluentApi that is similar to what Api.Create does.

Initially this method was called "Clone()" but I changed that, as the name "Clone" gave the impression that it copied the entire state, and that it could/should happen on every fluent operation. But it doesn't bother to copy the state - it just makes a new api instance that a thread can configure with the usual fluent methods. No not call it after any fluent methods or the current state will be discarded.