diff --git a/build-support/tools/nant/bin/NAnt.exe.config b/build-support/tools/nant/bin/NAnt.exe.config index 04f38c2d3..1054409b0 100644 --- a/build-support/tools/nant/bin/NAnt.exe.config +++ b/build-support/tools/nant/bin/NAnt.exe.config @@ -577,7 +577,7 @@ - + @@ -683,7 +683,7 @@ - + @@ -711,7 +711,7 @@ - + @@ -1045,7 +1045,7 @@ - + diff --git a/src/Spring/Spring.Core/Threading/AsyncLocalStorage.cs b/src/Spring/Spring.Core/Threading/AsyncLocalStorage.cs new file mode 100644 index 000000000..b27b1932d --- /dev/null +++ b/src/Spring/Spring.Core/Threading/AsyncLocalStorage.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections; +using System.Threading; + +namespace Spring.Threading +{ + /// + /// Implements by using a hashtable. + /// + /// Erich Eichinger + +#if NETSTANDARD + public class AsyncLocalStorage : IThreadStorage + { + + static AsyncLocal data; + + private static Hashtable Data + { + get + { + if (data == null) data = new AsyncLocal(); + return data.Value; + } + } + + /// + /// Retrieves an object with the specified name. + /// + /// The name of the item. + /// The object in the call context associated with the specified name or null if no object has been stored previously + public object GetData(string name) + { + return Data[name]; + } + + /// + /// Stores a given object and associates it with the specified name. + /// + /// The name with which to associate the new item. + /// The object to store in the call context. + public void SetData(string name, object value) + { + Data[name] = value; + } + + /// + /// Empties a data slot with the specified name. + /// + /// The name of the data slot to empty. + public void FreeNamedDataSlot(string name) + { + Data.Remove(name); + } + } +#endif +} \ No newline at end of file diff --git a/src/Spring/Spring.Core/Threading/LogicalThreadContext.cs b/src/Spring/Spring.Core/Threading/LogicalThreadContext.cs index 0f80c4d7f..ba807c340 100644 --- a/src/Spring/Spring.Core/Threading/LogicalThreadContext.cs +++ b/src/Spring/Spring.Core/Threading/LogicalThreadContext.cs @@ -48,7 +48,8 @@ public sealed class LogicalThreadContext /// private static IThreadStorage threadStorage = #if NETSTANDARD - new ThreadStaticStorage(); + //new ThreadStaticStorage(); + new AsyncLocalStorage(); #else new CallContextStorage(); #endif