AuctionSniper.Console.ConsoleAppHelper.WaitDisconnectingTo C# (CSharp) Method

WaitDisconnectingTo() public static method

public static WaitDisconnectingTo ( jabber.client.JabberClient inClient ) : void
inClient jabber.client.JabberClient
return void
        public static void WaitDisconnectingTo(JabberClient inClient)
        {
            if (! inClient.IsAuthenticated) return;

            var locker = new object();
            var connected = true;

            inClient.OnDisconnect += (s) => {
                lock (locker) {
                    connected = false;
                    Monitor.PulseAll(locker);
                }
            };

            while (true) {
                lock (locker) {
                    Monitor.Wait(locker, TimeSpan.FromMilliseconds(100));

                    if (! connected) break;
                }
            }
        }

Usage Example

Beispiel #1
0
            void IAuction.Disconnect()
            {
                this.NotToBeGCD.Close();
                ConsoleAppHelper.WaitDisconnectingTo(this.NotToBeGCD.Connection);

                mListener.AuctionDisconnected();
            }