Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            ConcreteCloneable concrete = new ConcreteCloneable();

            concrete.Id   = 1;
            concrete.Name = "Un nombre";

            ConcreteCloneable cloned = concrete.ShallowCopy() as ConcreteCloneable;

            if (cloned != null)
            {
                cloned.Id   = 3;
                cloned.Name = "Cambiado";
            }

            IObjectPool pool = ObjectPool.GetInstance();

            Parallel.For(0, 1000000, (i) =>
            {
                IPooledObject reusable = pool.GetConnection();

                reusable.DoSomething();

                reusable.Release();
            });
        }