Esempio n. 1
0
    public IMessageHandler PickupResponse(int int_2, int int_3)
    {
        Class73  class2;
        bool     flag = !Thread.CurrentThread.IsBackground;
        DateTime now  = DateTime.Now;
        string   id   = this.method_1(int_2, int_3);

Label_0074:
        class2 = this.safeDictionary_1.Get(id);
        if (class2 == null)
        {
            if (!((this.interface26_0 == null) || this.interface26_0.Connected))
            {
                throw new Exception("Network connection is disconnected!");
            }
            if (this.int_1 > 0)
            {
                TimeSpan span = (TimeSpan)(DateTime.Now - now);
                if (span.TotalSeconds >= this.int_1)
                {
                    throw new TimeoutException("Timeout waiting for reply!");
                }
            }
            if (flag)
            {
                WindowsHelper.DoWindowsEvents();
            }
            Thread.Sleep(5);
            goto Label_0074;
        }
        this.safeDictionary_1.Remove(id);
        return(class2.method_0());
    }
Esempio n. 2
0
        public NetMessage PickupResponse(int serviceKey, int corelationID)
        {
            bool isUIThraed = !Thread.CurrentThread.IsBackground;

            int count = (this.timeoutSec * 1000 / 50);

            if (this.timeoutSec <= 0)
            {
                count = int.MaxValue;
            }

            while ((count--) > 0)
            {
                NetMessage response = this.PopRespose(corelationID, serviceKey);

                if (response == null)
                {
                    if (isUIThraed)
                    {
                        WindowsHelper.DoWindowsEvents();
                    }
                    System.Threading.Thread.Sleep(50);
                }
                else
                {
                    return(response);
                }
            }

            throw new Exception("It's timeout for wait response !");
        }