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; }
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(); }
public MyRemoteService() { Console.WriteLine("MyRemoteObject.Constructor: New Object created"); param = new Param1(); }
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(); }
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); }
public bool SetValue(int newValue, Param1 param) { Request request = new Request("My Service", "SetValue", new object[] {newValue, param }); return pool.Request<bool>(request); }