zoukankan      html  css  js  c++  java
  • 访问双工服务

    View Code
    // Code in the MainPage.xaml.cs page.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using System.ServiceModel;
    using System.ServiceModel.Channels;
    using DuplexClient.OrderService;


    namespace DuplexClient
    {
    public partial class MainPage : UserControl
    {

    public MainPage()
    {
    InitializeComponent();

    // If using the PollingDuplexHttpBinding on the service
    EndpointAddress address = new EndpointAddress("http://localhost:19021/Service1.svc");
    PollingDuplexHttpBinding binding
    = new PollingDuplexHttpBinding(PollingDuplexMode.MultipleMessagesPerPoll);

    DuplexServiceClient proxy
    = new DuplexServiceClient(binding, address);

    // If using a NetTcpBinding on the service
    // DuplexServiceClient proxy = new DuplexServiceClient();
    proxy.ReceiveReceived += new EventHandler<ReceiveReceivedEventArgs>(proxy_ReceiveReceived);
    proxy.OrderAsync(
    "Widget", 3);
    reply.Text
    = "Sent order of 3 Widgets." + Environment.NewLine;

    }

    void proxy_ReceiveReceived(object sender, ReceiveReceivedEventArgs e)
    {
    if (e.Error == null)
    {
    reply.Text
    += "Service reports Widget order is " + e.order.Status + "." + Environment.NewLine;

    if (e.order.Status == OrderStatus.Completed)
    {
    reply.Text
    += "Here is the completed order:" + Environment.NewLine;

    foreach (string order in e.order.Payload)
    {
    reply.Text
    += order + Environment.NewLine;
    }
    }

    }
    }

    }
    }

  • 相关阅读:
    怎样修改原型对象prototype
    怎样获取构造函数的名字
    怎样把实例对象当构造函数用
    怎样理解prototype对象的constructor属性
    怎样理解构造函数的原型对象prototype
    怎样给回调函数绑定this
    怎样绑定this
    怎样理解数组的空元素empty与undefined的区别
    怎样找出数组中的最大数值
    怎样调用对象的原生方法
  • 原文地址:https://www.cnblogs.com/landexia/p/1994439.html
Copyright © 2011-2022 走看看