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;
    }
    }

    }
    }

    }
    }

  • 相关阅读:
    关于http头
    关于js中的命名
    PHP之APC缓存详细介绍
    找回Windows Vista桌面的IE7.0图标
    查看操作系统是不是中文正式版?
    如何判断XP是否已激活
    Vista取消默认共享
    今天是儿童节,祝福儿子节日快乐!
    天天锻炼身体好!
    如何查看你的XP SP2是否原版?
  • 原文地址:https://www.cnblogs.com/landexia/p/1994439.html
Copyright © 2011-2022 走看看