示例#1
0
        void GetLuggage()
        {
            while (true)
            {
                Monitor.Enter(IncomingLuggage);
                while (IncomingLuggage.Count == 0)
                {
                    //Wait for luggage to come in, and immediately send it out
                    Monitor.Wait(IncomingLuggage);
                }
                LuggageSent?.Invoke(this, EventArgs.Empty);

                for (int i = 0; i < rnd.Next(0, IncomingLuggage.Count); i++)
                {
                    SplitLuggage(IncomingLuggage.Dequeue());
                }



                Monitor.Exit(IncomingLuggage);

                Thread.Sleep(rnd.Next(100, 300));
            }
        }
示例#2
0
文件: Simulation.cs 项目: KavTV/H2
 private void Splitter_LuggageSent(object sender, EventArgs e)
 {
     LuggageSent?.Invoke(this, e);
 }