public void TravelAgencyFun() { while (Program.AirlineThread1.IsAlive || Program.AirlineThread2.IsAlive || Program.AirlineThread3.IsAlive) { if (this.flag) { OrderClass obj = new OrderClass(); obj = generate_obj(); Encoder encode_test = new Encoder(); encodedOrderString = encode_test.encryptString(obj); stopWatch.Start(); MultiCellBuffer.setOneCell(encodedOrderString); //Console.WriteLine("Travel Agency Sender id {0} receiver id {1} Amount {2} Unitprice {3}", obj.get_senderId(), obj.get_receiverId(), obj.get_amount(), obj.get_unitprice()); OrderCount++; this.flag = false; } } }
public void AirlineFun() { while (Program.AirlineThread1.IsAlive || Program.AirlineThread2.IsAlive || Program.AirlineThread3.IsAlive || NullCount < 6) { string multiCell = MultiCellBuffer.getOneCell(this.name); if (multiCell != null) { NullCount = 0; Decoder decode_test = new Decoder(); OrderClass obj = new OrderClass(); obj = decode_test.decryptString(multiCell); Console.WriteLine("\n\n------------ ORDER SENT --------------"); Console.WriteLine("Travel {0} is placing an order for {1} tickets to {2}", obj.get_senderId(), obj.get_amount(), obj.get_receiverId()); Console.WriteLine("The price for each ticket is : ${0}", obj.get_unitprice()); Console.WriteLine("-------------------------------------------\n\n"); this.remaining_tickets = this.remaining_tickets - obj.get_amount(); //Console.WriteLine("Remaining tic {0} {1}", this.remaining_tickets, obj.get_receiverId()); if (this.remaining_tickets < 0) { //Console.WriteLine("Amount not processed is {0} {1}", obj.get_amount(), obj.get_receiverId()); obj.set_amount(0); } OrderProcessing order = new OrderProcessing(); Thread OrderProcessingThread = new Thread(() => order.OrderProcessingFun(obj)); OrderProcessingThread.Start(); OrderProcessingThread.Join(); //Console.WriteLine("{0} Thread created", obj.get_receiverId()); } else { NullCount++; } //Thread.Sleep(1000); } }