예제 #1
0
        static void Main()
        {
            HttpChannel ch = new HttpChannel();
            ChannelServices.RegisterChannel(ch,false);
            INumber robj = (INumber)Activator.GetObject(
                typeof(INumber),
                "http://localhost:1234/RemoteNumber.soap");
            Console.WriteLine("Client.Main(): Referencia para objecto remoto adquirida");

            DateTime start = System.DateTime.Now;
            Console.WriteLine("Client.Main(): Vai colocar novo valor=42");

            // Invocação Assíncrona do método setValue()
            DelSetValue svdel = new DelSetValue(robj.setValue);
            IAsyncResult svasyncres = svdel.BeginInvoke(42, null, null);
            // Invocação Assíncrona do método add()
            DelAdd adddel = new DelAdd(robj.add);
            IAsyncResult addsyncres = adddel.BeginInvoke(42,100,null, null);

            // Continua a realizar Acções

            // Obter os resultados da invocação assíncrona
            Console.WriteLine("Client.Main(): Obter resultado do SetValue()");
            svdel.EndInvoke(svasyncres);
            Console.WriteLine("Client.Main(): Obter resultado de add()");
            int soma = adddel.EndInvoke(addsyncres);
            Console.WriteLine("Client.Main(): soma: {0}", soma);

            Console.WriteLine("Client.Main(): Vai ler o valor");
            int tmp = robj.getValue();
            Console.WriteLine("Client.Main(): Novo valor no server: {0}", tmp);

            DateTime end = System.DateTime.Now;
            TimeSpan texec = end.Subtract(start);
            Console.WriteLine("Client.Main(): Tempo de Execução: {0}s:{1}ms", texec.Seconds, texec.Milliseconds);

            Console.ReadLine();
        }
예제 #2
0
파일: Program.cs 프로젝트: pepipe/ISEL
        static void Main()
        {
            HttpChannel ch = new HttpChannel();
            ChannelServices.RegisterChannel(ch,false);
            INumber robj = (INumber)Activator.GetObject(
                typeof(INumber),
                "http://localhost:1234/RemoteNumber.soap");

            Console.WriteLine("Client.Main(): Vai colocar novo valor=100");
            // Invocação Assíncrona do método SetValue
            DelSetValue svdel = new DelSetValue(robj.setValue);

            AsyncCallback mycallback = new AsyncCallback(setValueCompleted);
            start = System.DateTime.Now;
            IAsyncResult svasyncres = svdel.BeginInvoke(100, mycallback, "set value com 100");
            while (!svasyncres.IsCompleted)
            {   // O cliente continua a fazer trabalho até a operação terminar
                Console.WriteLine("espera fim operação");
                Console.WriteLine("novo valor= {0}", robj.getValue());
                Thread.Sleep(1000);
            }
            Console.WriteLine("novo valor= {0}", robj.getValue());

            AsyncCallback myCbadd = new AsyncCallback(AddCompleted);
            DelAdd adddel = new DelAdd(robj.add);
            IAsyncResult svasyncresadd = adddel.BeginInvoke(100, 200, myCbadd, "add 100 com 200");

            while (!svasyncresadd.IsCompleted)
            {   // O cliente continua a fazer trabalho até a operação terminar
                Console.WriteLine("espera fim operação add");

                Thread.Sleep(1000);
            }
            Console.WriteLine("RES="+resAdd);

            Console.ReadLine();
        }
예제 #3
0
 public vip(DelSetValue del)
 {
     InitializeComponent();
     this.del = del;
 }
예제 #4
0
 public Form2(DelSetValue del) : this()
 {
     this._del = del;
 }