Esempio n. 1
0
        static void AddThreadHandle()
        {
            Random rnd = new Random();

            while (true)
            {
                mutex.WaitOne();
                int  toolNumber = rnd.Next(1, 4);
                Tool tool       = null;
                switch (toolNumber)
                {
                case 1:
                    tool = tf.CreateAirplane("Thread Airplane");
                    break;

                case 2:
                    tool = tf.CreateBike("Thread Bike");
                    break;

                case 3:
                    tool = tf.CreateSubmarine("Threa Submarine");
                    break;
                }
                tb.AddTool(tool);
                Console.WriteLine("Created tool: " + tool.Name);

                mutex.ReleaseMutex();
                System.Threading.Thread.Sleep(SleepTime);
            }
        }
Esempio n. 2
0
        static void createTestTools(ToolBox tb)
        {
            ToolFactory tf = new ToolFactory();

            var ma1 = tf.CreateAirplane("myAirplane1");

            ma1.Age       = 2;
            ma1.BaseWorth = new Worth(5, 10);
            tb.AddTool(ma1);
            ma1.Birthday();

            var mb1 = tf.CreateBike("myBike");

            mb1.Age       = 6;
            mb1.BaseWorth = new Worth(60, 30);
            tb.AddTool(mb1);

            var ms1 = tf.CreateSubmarine("mySubmarine");

            ms1.Age       = 9;
            ms1.BaseWorth = new Worth(30, 20);
            tb.AddTool(ms1);

            tb.DeleteTool(ms1);

            tb.ChangeAccelarate(100);
        }