示例#1
0
        public string HalloWorld4()
        {
            Console.WriteLine("测试CallbackContract属性");
            IHelloCallbackContract callerProxy = OperationContext.Current.GetCallbackChannel <IHelloCallbackContract>();

            callerProxy.onTextCallback("CallBack");
            Console.WriteLine("当前实例的哈希值:{0}", this.GetHashCode().ToString("x"));
            return("HalloWorld4");
        }
示例#2
0
        public void Hello(string greeting)
        {
            Console.WriteLine("Caller sent: " + greeting);
            Console.WriteLine("Session ID: " + OperationContext.Current.SessionId);
            Console.WriteLine("Waiting two seconds before returning call.");
            // Put a slight delay to demonstrate asynchronous behavior on client.
            Thread.Sleep(2000);
            IHelloCallbackContract callerProxy
                = OperationContext.Current.GetCallbackChannel <IHelloCallbackContract>();
            string response = "Service object " + this.GetHashCode().ToString() + " received: " + greeting;

            Console.WriteLine("Sending back: " + response);
            callerProxy.Reply(response);
        }