예제 #1
0
        private static void InvokeOnceByNewClient(object o)
        {
            Console.WriteLine("ThreadID: {0}", Thread.CurrentThread.ManagedThreadId.ToString());
            var waitHandle = o as CountdownEvent;

            var stopwatch = TimeElapsedTracer.CreateWatchAndStartTracing();

            ProductServiceProxy productService = new ProductServiceProxy("ProductServiceHttp");

            var elapsed = TimeElapsedTracer.TraceRestart("创建Proxy", stopwatch, TimeSpan.Zero);

            productService.Open();

            Console.WriteLine("Start tid {0}", Thread.CurrentThread.ManagedThreadId.ToString());
            var product = productService.GetProduct("XXXX");

            Console.WriteLine("END tid {0}", Thread.CurrentThread.ManagedThreadId.ToString());

            elapsed = TimeElapsedTracer.TraceRestart("调用proxy", stopwatch, elapsed);

            (productService as IDisposable).Dispose();
            TimeElapsedTracer.TraceStop("dispose proxy", stopwatch, elapsed);


            TimeElapsedTracer.TraceStopAndReset("全部", stopwatch);


            waitHandle.SetOne();
        }
예제 #2
0
        private static void InvokeOnceByCachedFactory(object o)
        {
            Console.WriteLine("ThreadID: {0}", Thread.CurrentThread.ManagedThreadId.ToString());
            var waitHandle = o as CountdownEvent;

            var stopwatch = TimeElapsedTracer.CreateWatchAndStartTracing();

            var proxy   = factory.CreateChannel();
            var elapsed = TimeElapsedTracer.TraceRestart("创建Proxy", stopwatch, TimeSpan.Zero);

            (proxy as IClientChannel).Open();
            var product = proxy.GetProduct("xxxx");

            elapsed = TimeElapsedTracer.TraceRestart("调用proxy", stopwatch, elapsed);
            Console.WriteLine(elapsed.ToString());
            (proxy as IClientChannel).Close();
            TimeElapsedTracer.TraceStop("dispose proxy", stopwatch, elapsed);

            TimeElapsedTracer.TraceStopAndReset("全部", stopwatch);

            waitHandle.SetOne();
        }