Ejemplo n.º 1
0
        internal void AsyncTimeoutResultCallTest()
        {
            ManualResetEvent eventa = new ManualResetEvent(false);

            DateTime start = DateTime.Now;

            AsyncCallResultDelegate delegateInstance =
                delegate(ISuperPoolClient client, AsyncResultParams parameters)
            {
                TimeSpan time = DateTime.Now - start;
                Console.WriteLine("Async call result received in " + time.TotalMilliseconds + "ms.");
                eventa.Set();
                string p = parameters.Result as string;
            };

            Client1.CallAll <ITestInterface>(delegateInstance, 152, TimeSpan.FromSeconds(2)).AsyncResultMethod(500);

            eventa.WaitOne(60000);

            if (Client1.PendingSyncCallsCount != 1)
            {
                throw new Exception("Pending sync calls count not 1.");
            }

            // Allow time for the client GC to gather the call.
            Thread.Sleep(SuperPoolClient.GarbageCollectorIntervalMs * 3);

            if (Client1.PendingSyncCallsCount != 0)
            {
                throw new Exception("Pending sync calls count not 0.");
            }
        }
Ejemplo n.º 2
0
        internal void AsyncTimeoutResultCallTestException()
        {
            ManualResetEvent eventa = new ManualResetEvent(false);

            AsyncCallResultDelegate delegateInstance =
                delegate(ISuperPoolClient client, AsyncResultParams parameters)
            {
                if (parameters.Exception == null)
                {    // No exception was received, this is not expected.
                }
                else
                {
                    eventa.Set();
                }
            };

            Client1.CallAll <ITestInterface>(delegateInstance, 152, TimeSpan.FromSeconds(2)).ExceptionMethod();

            if (eventa.WaitOne(20000) == false)
            {
                throw new Exception("Test failed due to no exception received.");
            }
        }