All pastes #562450 Raw Edit

Someone

public text v1 · immutable
·published 2007-06-12 19:59 UTC
rendered paste body
        public static bool WaitForPacket(RealmServerPacket packet, PacketConfirmation confirmation, int timeOut)
        {
            bool isBusy = true;

            Packet.Instance.Sniffer.AddAsyncListener(packet,
                delegate(object sender, PacketEventArgs args)
                {
                    Type t = args.Packet.GetType();

                    if (confirmation(args.Packet))
                        isBusy = false;
                });

            DateTime start = DateTime.Now;

            while (isBusy)
            {
                if (((TimeSpan)DateTime.Now.Subtract(start)).TotalMilliseconds > timeOut)
                    return false;

                System.Threading.Thread.Sleep(10);
            }

            return true;
        }















        public static bool WaitForPacket(GameServerPacket packet, PacketConfirmation confirmation, int timeOut)
        {
            bool isBusy = true;

            Packet.Instance.Sniffer.AddAsyncListener(packet,
                delegate(object sender, PacketEventArgs args)
                {
                    Type t = args.Packet.GetType();

                    if (confirmation(args.Packet))
                        isBusy = false;
                });

            DateTime start = DateTime.Now;

            while (isBusy)
            {
                if (((TimeSpan)DateTime.Now.Subtract(start)).TotalMilliseconds > timeOut)
                    return false;

                System.Threading.Thread.Sleep(10);
            }

            return true;
        }