NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Thread Relative Statics HowTo

Marking fields as Thread Relative

class Foo
{
   int a;
   static int b;
[ThreadStaticAttribute()]
   static int c;

   int d=5;
   static int e=6;
    [ThreadStatic()]
   static int f=7;

   Foo()
   {
      a = 1;
      b = 2;
      c = 3;
   }

   void Method1()
   {
      Console.WriteLine(“{0}”, a);
      Console.WriteLine(“{0}”, b);
      Console.WriteLine(“{0}”, c);
      Console.WriteLine(“{0}”, d);
      Console.WriteLine(“{0}”, e );
      Console.WriteLine(“{0}”, f );
   }
}

Instance member field

a and d are instance members.

a. Instance member field. Uninitialized.

d. Instance member field. Initialized.

class static member field

b. class static member field. Uninitialized.

e. class static member field. Initialized.

The static is unique for the AppDomain.

thread relative static member field

c. thread relative static member field. Uninitialized.

f. thread relative static member field. Initialized.

The static is unique for the thread. The member field is not shared across threads.