Ejemplo n.º 1
0
        public async Task <Plane> CarryOutMaintenanceAsync(Plane plane, CheckNeeded cheks, CancellationToken ct = default(CancellationToken))
        {
            if (plane == null)
            {
                throw new ArgumentNullException("Plane is null");
            }
            if (cheks == CheckNeeded.None)
            {
                return(plane);
            }

            await Task.Run(() => {
                switch (cheks)
                {
                case CheckNeeded.A_Check:
                    Debug.WriteLine("A-check started.");
                    Thread.Sleep(750);
                    Debug.WriteLine("A-check successfuly completed.");
                    break;

                case CheckNeeded.B_Check:
                    Debug.WriteLine("B-check started.");
                    Thread.Sleep(1250);
                    Debug.WriteLine("B-check successfuly completed.");
                    break;

                case CheckNeeded.C_Check:
                    Debug.WriteLine("C-check started.");
                    Thread.Sleep(2000);
                    plane.FlightHours = 0;
                    Debug.WriteLine("C-check successfuly completed.");
                    break;

                case CheckNeeded.D_Check:
                    Debug.WriteLine("D-check started.");
                    Thread.Sleep(4000);
                    plane.LastHeavyMaintenance = DateTime.Now;
                    plane.FlightHours          = 0;
                    Debug.WriteLine("D-check successfuly completed.");
                    break;

                default:
                    break;
                }
            });

            return(plane);
        }
Ejemplo n.º 2
0
        public Plane CarryOutMaintenance(Plane plane, CheckNeeded checks)
        {
            if (plane == null)
            {
                throw new ArgumentNullException("Plane is null");
            }
            if (checks == CheckNeeded.None)
            {
                return(plane);
            }

            switch (checks)
            {
            case CheckNeeded.A_Check:
                Debug.WriteLine("A-check started.");
                Thread.Sleep(750);
                Debug.WriteLine("A-check successfuly completed.");
                break;

            case CheckNeeded.B_Check:
                Debug.WriteLine("B-check started.");
                Thread.Sleep(1250);
                Debug.WriteLine("B-check successfuly completed.");
                break;

            case CheckNeeded.C_Check:
                Debug.WriteLine("C-check started.");
                Thread.Sleep(2000);
                plane.FlightHours = 0;
                Debug.WriteLine("C-check successfuly completed.");
                break;

            case CheckNeeded.D_Check:
                Debug.WriteLine("D-check started.");
                Thread.Sleep(4000);
                plane.LastHeavyMaintenance = DateTime.Now;
                plane.FlightHours          = 0;
                Debug.WriteLine("D-check successfuly completed.");
                break;

            default:
                break;
            }

            return(plane);
        }