Example #1
0
        static void Main(string[] args)
        {
            RemotingConfiguration.Configure("HelloClient.exe.config");

            Hello obj = new Hello();

            if (obj == null)
            {
                Console.WriteLine("could not locate server");
                return;
            }

             CallContextData cookie = new CallContextData();
             cookie.Data = "information for the server";
             CallContext.SetData("mycookie", cookie);
             for (int i=0; i< 5; i++)
             {
            Console.WriteLine(obj.Greeting("Christian"));
             }

            for (int i=0; i< 5; i++)
            {
                Console.WriteLine(obj.Greeting("Christian"));
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            TrackingServices.RegisterTrackingHandler(new TrackingHandler());

            ChannelServices.RegisterChannel(new TcpClientChannel());
            ChannelServices.RegisterChannel(new HttpClientChannel());

            RemotingConfiguration.RegisterWellKnownClientType(
                typeof(Wrox.ProfessionalCSharp.Hello),
                "tcp://localhost:8086/Hi");

            /*			Hello obj = (Hello)Activator.GetObject(
                typeof(Wrox.ProfessionalCSharp.Hello),
                "tcp://localhost:8086/Hi");
            */

            Hello obj = new Hello();
            //	Hello obj = (Hello)RemotingServices.Connect(typeof(Wrox.ProfessionalCSharp.Hello),
            //		"http://localhost:8085/Hi");

            if (obj == null)
            {
                Console.WriteLine("could not locate server");
                return;
            }

            for (int i=0; i< 5; i++)
            {
                Console.WriteLine(obj.Greeting("Christian"));
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            RemotingConfiguration.Configure("HelloClient.exe.config");

            Hello obj = new Hello();

            if (obj == null)
            {
                Console.WriteLine("could not locate server");
                return;
            }

            for (int i=0; i< 5; i++)
            {
                Console.WriteLine(obj.Greeting("Christian"));
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            RemotingConfiguration.Configure("HelloClient.exe.config");

            Hello obj = new Hello();

            if (obj == null)
            {
                Console.WriteLine("could not locate server");
                return;
             }

             // synchronous:
             // greeting = obj.Greeting("Christian");

             // asynchronous:
             GreetingDelegate d = new GreetingDelegate(obj.Greeting);
             Console.WriteLine("Starting remote method");
             IAsyncResult ar = d.BeginInvoke("Christian", null, null);

             // do some work
             Console.WriteLine("Do some other work");

             ar.AsyncWaitHandle.WaitOne();

             if (ar.IsCompleted)
             {
            greeting = d.EndInvoke(ar);
             }

             Console.WriteLine(greeting);

            /*
             Console.WriteLine("starting long call");
             obj.TakeAWhile(10000);
             Console.WriteLine("finished long call");
            */
        }