Exemplo n.º 1
0
        public bool SetValue(int newval, Param1 p)
        {
//            Console.WriteLine("MyRemoteService.setValue(): old {0} new {1}",
//                                  myvalue, newval);
            for (int i = 0; i < 1000; i++)
            {
            	param.Id = p.Id;
				param.UserName = p.UserName;
				myvalue = newval;
			}
//            Console.WriteLine(" .setValue() -> value is now set");
            return true;
        }
Exemplo n.º 2
0
        public static void Main(string[] arg)
        {
        	int n = 10000;
        	var proxy = new MyRemoteService();
			var param = new Param1();
			Console.WriteLine("Client set value for remote service");
			Stopwatch watch = new Stopwatch();
			watch.Start();
			for (int i = 0; i < n; i++)
			{
				var sucess = proxy.SetValue(i, param);
//				Console.WriteLine(i + sucess.ToString());
			}
			watch.Stop();
			Console.WriteLine(string.Format("Client seted value for remote service. Execution took {0} miliseconds", (float)watch.ElapsedMilliseconds / n));
        	Console.ReadLine();
//            ServiceHost host = new ServiceHost(11885);
//            Console.WriteLine("host open ");
//            host.Container.RegisterService("My Service",
//                                new MyRemoteService(), false);
//            Console.WriteLine("registed service");
//            host.Open();
//            Console.ReadLine();
//            Console.WriteLine("Closing");
//            host.Close();
        }
Exemplo n.º 3
0
 public MyRemoteService()
 {
     Console.WriteLine("MyRemoteObject.Constructor: New Object created");
     param = new Param1();
 }
Exemplo n.º 4
0
        public static void Main(string[] arg)
        {
            int n = 10000;
            ServiceContainer container = new ServiceContainer();
            proxy = new MyProxy(new SocketPool(1, container,
                "127.0.0.1:11885"));
            DateTime start, end;
            TimeSpan duration;
            Param1 param = new Param1();
            param.Id = 10;
            param.UserName = "******";
            Console.WriteLine("Client set value for remote service");
            Stopwatch watch = new Stopwatch();
            watch.Start();
            for (int i = 0; i < n; i++)
            {
                var sucess = proxy.SetValue(i, param);
//                Console.WriteLine(i + sucess.ToString());
            }
            watch.Stop();
            Console.WriteLine(string.Format("Client seted value for remote service. Execution took {0} miliseconds", (float) watch.ElapsedMilliseconds / n));
            /*Console.WriteLine("Client get value from remote service");
            start = DateTime.Now;
            int result = proxy.GetValueSimple();
            end = DateTime.Now;
            duration = end.Subtract(start);
            Console.WriteLine("Client geted from remote service. value = {0}. Execution took {1} miliseconds", result, duration.TotalMilliseconds);
            */
            Console.WriteLine("press anyone key to exit");
            Console.ReadLine();
        }
Exemplo n.º 5
0
 public void SetValue(int newValue, Param1 param, WaitCallback CallbackMethod, object context)
 {
     Request request = new Request("My Service", "SetValue", new object[] { newValue, param });
     pool.BeginRequest(request, CallbackMethod, context);
 }
Exemplo n.º 6
0
 public bool SetValue(int newValue, Param1 param)
 {
     Request request = new Request("My Service", "SetValue", new object[] {newValue, param });
     return pool.Request<bool>(request);
 }