1: class Program
2: {
3: static void Main(string[] args)
4: {
5: object _value = "same_value";
6:
7: try
8: {
9: LogicalThreadContext.SetData("KEY", _value);
10: Console.WriteLine("DefaultContextStorage: " + LogicalThreadContext.GetData("KEY"));
11: LogicalThreadContext.FreeNamedDataSlot("KEY");
12: }
13: catch { Console.WriteLine("DefaultContextStorage non disponibile."); }
14:
15: try
16: {
17: LogicalThreadContext.SetStorage(new HybridContextStorage());
18: LogicalThreadContext.SetData("KEY", _value);
19: Console.WriteLine("HybridContextStorage: " + LogicalThreadContext.GetData("KEY"));
20: LogicalThreadContext.FreeNamedDataSlot("KEY");
21: }
22: catch { Console.WriteLine("HybridContextStorage non disponibile."); }
23:
24: try
25: {
26: LogicalThreadContext.SetStorage(new HttpContextStorage());
27: LogicalThreadContext.SetData("KEY", _value);
28: Console.WriteLine("HttpContextStorage: " + LogicalThreadContext.GetData("KEY"));
29: LogicalThreadContext.FreeNamedDataSlot("KEY");
30: }
31: catch { Console.WriteLine("HttpContextStorage non disponibile."); }
32:
33: Console.Read();
34: }
35: }