Context Manipulator : ContextProperty : Development C# Examples


C# Examples » Development » ContextProperty »

 

Context Manipulator









    
using  System;
using  System.Runtime.Remoting.Contexts;
using  System.Threading;

public  class  SportsCar  {
        public  SportsCar()  {
                Context  ctx  =  Thread.CurrentContext;
                Console.WriteLine("{0}  object  in  context  {1}",  this.ToString(),  ctx.ContextID);
                foreach  (IContextProperty  itfCtxProp  in  ctx.ContextProperties)
                        Console.WriteLine("->  Ctx  Prop:  {0}",  itfCtxProp.Name);
        }
}

[Synchronization]
public  class  SportsCarTS  :  ContextBoundObject  {
        public  SportsCarTS()  {
                Context  ctx  =  Thread.CurrentContext;
                Console.WriteLine("{0}  object  in  context  {1}",  this.ToString(),  ctx.ContextID);
                foreach  (IContextProperty  itfCtxProp  in  ctx.ContextProperties)
                        Console.WriteLine("->  Ctx  Prop:  {0}",  itfCtxProp.Name);
        }
}


class  Program  {
        static  void  Main(string[]  args)  {
                SportsCar  sport  =  new  SportsCar();
                Console.WriteLine();

                SportsCar  sport2  =  new  SportsCar();
                Console.WriteLine();

                SportsCarTS  synchroSport  =  new  SportsCarTS();
                Console.ReadLine();
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Development
» ContextProperty