Пример #1
0
 static void Main(string[] args)
 {
     try
     {
         IStateName            proxy  = XmlRpcProxyGen.Create <IStateName>();
         RequestResponseLogger logger = new RequestResponseLogger();
         logger.Directory = "C:/temp";
         proxy.AttachLogger(logger);
         Console.WriteLine("Synchronous call");
         string ret = proxy.GetStateName(45);
         Console.WriteLine("state #45 is {0}", ret);
         Console.WriteLine("Asynchronous call");
         IAsyncResult asr = proxy.BeginGetStateName(46);
         asr.AsyncWaitHandle.WaitOne();
         string aret = proxy.EndGetStateName(asr);
         Console.WriteLine("state #46 is {0}", aret);
     }
     catch (XmlRpcFaultException fex)
     {
         Console.WriteLine(fex.FaultString);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Пример #2
0
        public void MakeAsynchronousCallWait()
        {
            IStateName   proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));
            IAsyncResult asr2  = proxy.BeginGetStateName(1);

            asr2.AsyncWaitHandle.WaitOne();
            string ret2 = proxy.EndGetStateName(asr2);

            Assert.AreEqual("Alabama", ret2);
        }
Пример #3
0
        public void MakeAsynchronousCallCallbackNoState()
        {
            IStateName proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));

            _evt = new ManualResetEvent(false);
            IAsyncResult asr3 = proxy.BeginGetStateName(1, StateNameCallbackNoState);

            _evt.WaitOne();
            Assert.AreEqual(null, _excep, "Async call threw exception");
            Assert.AreEqual("Alabama", _ret);
        }
Пример #4
0
        public void MakeAsynchronousCallIsCompleted()
        {
            IStateName   proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));
            IAsyncResult asr1  = proxy.BeginGetStateName(1);

            while (asr1.IsCompleted == false)
            {
                System.Threading.Thread.Sleep(10);
            }
            string ret1 = proxy.EndGetStateName(asr1);

            Assert.AreEqual("Alabama", ret1);
        }
Пример #5
0
        public void AsynchronousFaultException()
        {
            IStateName   proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));
            IAsyncResult asr   = proxy.BeginGetStateName(100);

            asr.AsyncWaitHandle.WaitOne();
            try
            {
                string ret = proxy.EndGetStateName(asr);
                Assert.Fail("exception not thrown on async call");
            }
            catch (XmlRpcFaultException fex)
            {
                Assert.AreEqual(1, fex.FaultCode);
                Assert.AreEqual("Invalid state number", fex.FaultString);
            }
        }
Пример #6
0
        private void butGetName_Click(object sender, System.EventArgs e)
        {
            IStateName betty = XmlRpcProxyGen.Create <IStateName>();

            betty.Timeout = 10000;
            try
            {
                AsyncCallback   acb        = new AsyncCallback(GetStateNameCallback);
                int             num        = Convert.ToInt32(txtStateNumber.Text);
                BettyAsyncState asyncState = new BettyAsyncState(num, this);
                IAsyncResult    asr        = betty.BeginGetStateName(num, acb, asyncState);
                if (asr.CompletedSynchronously)
                {
                    string ret = betty.EndGetStateName(asr);
                    AppendSuccess(num, ret);
                }
            }
            catch (Exception ex)
            {
                AppendException(ex);
            }
        }