当前位置: 首页>>代码示例>>C#>>正文


C# ServiceHost.BeginOpen方法代码示例

本文整理汇总了C#中System.ServiceModel.ServiceHost.BeginOpen方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceHost.BeginOpen方法的具体用法?C# ServiceHost.BeginOpen怎么用?C# ServiceHost.BeginOpen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ServiceModel.ServiceHost的用法示例。


在下文中一共展示了ServiceHost.BeginOpen方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HostForm

        public HostForm()
        {
            InitializeComponent();

            Current = this;

            host = new ServiceHost<CounterService>();
            host.Opening += new EventHandler(host_StateChanged);
            host.Opened += new EventHandler(host_StateChanged);
            host.Closing += new EventHandler(host_StateChanged);
            host.Closed += new EventHandler(host_StateChanged);
            host.Faulted += new EventHandler(host_StateChanged);
            host.BeginOpen(null, null);
        }
开发者ID:sajjadahmadi,项目名称:wcf-examples,代码行数:14,代码来源:HostForm.cs

示例2: Start

 public static void Start()
 {
     if (crs == null && customResolver == null)
     {
         crs = new CustomPeerResolverService();
         crs.ControlShape = false;
         customResolver = new ServiceHost(crs);
         crs.Open();
         customResolver.BeginOpen((AsyncCallback)((t) =>
         {
             App.Log.Info("Служба разрешения имен запущена успешно!");
             App.ViewModel.AddLogMessage("Служба разрешения имен запущена успешно!");
         }), null);//.Open();
     }
 }
开发者ID:ericQiang,项目名称:selector-theater,代码行数:15,代码来源:PeerResolver.cs

示例3: HostForm

        public HostForm(string baseAddress)
        {
            InitializeComponent();

            this.Text = baseAddress;

            Current = this;

            host = new ServiceHost<CounterService>(new Uri(baseAddress));
            host.Opening += new EventHandler(host_StateChanged);
            host.Opened += new EventHandler(host_StateChanged);
            host.Closing += new EventHandler(host_StateChanged);
            host.Closed += new EventHandler(host_StateChanged);
            host.Faulted += new EventHandler(host_StateChanged);
            host.BeginOpen(null, null);
        }
开发者ID:sajjadahmadi,项目名称:wcf-examples,代码行数:16,代码来源:HostForm.cs

示例4: Program

        private Program()
        {
            GraphInit();
            _connection = TcpConnection.Instance;

            Console.WriteLine("Airline Server");

            var soapHost = new ServiceHost(typeof(SOAPService));
            soapHost.BeginOpen(null, soapHost);

            var listener = new TcpListener(IPAddress.Parse("127.0.0.1"), 7000);
            listener.Start();
            EndPoint remote = null;

            _discountWorker = new Thread(() => ApplyDiscounts());
            _discountWorker.Name = "Discount Worker";
            _discountWorker.Start();

            _removeWorker = new Thread(() => ApplyDiscounts());
            _removeWorker.Name = "Remove Worker";
            _removeWorker.Start();

            while (true)
            {
                try
                {
                    var current = listener.AcceptSocket();
                    remote = current.RemoteEndPoint;

                    Console.WriteLine("200 OK - Connection accepted from {0}",
                        remote);

                    var clientThread = new Thread(() => _connection.ManageClient(current));
                    clientThread.Start();
                }
                catch (SocketException se)
                {
                    if (remote == null)
                        Console.WriteLine("410 GONE - Connection not established");
                    else
                        Console.WriteLine("410 GONE - Connection with {0} was interrupted",
                            remote);
                    Debug.WriteLine(se.Message);
                }
            }
        }
开发者ID:nesbocaj,项目名称:project-early-2013,代码行数:46,代码来源:Program.cs

示例5: OpenServices

        private void OpenServices()
        {
            // Create a singleton instance for the host
            ChatService chatService = new ChatService(this);
            chatServiceHost = new ServiceHost(chatService, this.localAddress);

            // Create a discovery behavior
            EndpointDiscoveryBehavior endpointDiscoveryBehavior = new EndpointDiscoveryBehavior();

            // Add an extension element with the username
            endpointDiscoveryBehavior.Extensions.Add(
                new XElement(
                    "root",
                    new XElement("Name", this.userName)));

            // Find the endpoint
            ServiceEndpoint simpleEndpoint =
                this.chatServiceHost.Description.Endpoints.Find(typeof(ISimpleChatService));

            // Add our behavior to the endpoint before opening it
            simpleEndpoint.Behaviors.Add(endpointDiscoveryBehavior);

            ShowStatus("Opening chat service...");
            chatServiceHost.BeginOpen(
                (result) =>
                {
                    chatServiceHost.EndOpen(result);
                    ShowStatus("Chat service ready");
                },
                null);
            OpenAnnouncementService();
        }
开发者ID:Helen1987,项目名称:edu,代码行数:32,代码来源:SimpleChat.cs

示例6: btn_OpenSystem_Click

        /// <summary>
        /// 系统打开
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_OpenSystem_Click(object sender, RoutedEventArgs e)
        {
            if (IsOpenSystem)
            {
                MessageBox.Show("系统已启动!");
                return;
            }
            try
            {
                //交通管制串口
                if (SPComControl == null)
                {
                    ControlCOMInit();
                }
                if (!SPComControl.IsOpen)
                {
                    SPComControl.portname = GlobalPara.Gcontrolcomname;
                    SPComControl.Open();
                    SPComControl.DiscardInBuffer();
                    SPComControl.Write(buf_trafficctl, 0, buf_trafficctl.Length);
                }

                //叫料系统串口
                if (GlobalPara.IsCallFun)
                {
                    if (SPComCall == null)
                    {
                        CallCOMInit();
                    }
                    if (!SPComCall.IsOpen)
                    {
                        SPComCall.portname = GlobalPara.Gcallcomname;
                        SPComCall.Open();
                        SPComCall.DiscardInBuffer();
                    }
                }
            }
            catch (System.Exception ex)
            {
                if (SPComControl != null)
                {
                    SPComControl.Close();
                }
                if (SPComCall != null)
                {
                    SPComCall.Close();
                }
                MessageBox.Show(ex.Message);
                return;
            }

            Array.Clear(buf_virtualtrafficctl, 0, buf_virtualtrafficctl.Length);
            if (!pageShift.IsEnabled && cbautoshift.IsChecked.Value)
            {
                pageShift.Start();//开始计时,开始循环
            }
            if (!DataTimer.IsEnabled)
            {
                SPComControl.DiscardInBuffer();
                DataTimer.Start();//数据发送Timers
            }
            if (SPComControl.IsOpen)
            {
                imgCOM.Source = new BitmapImage(new Uri("pack://application:,,,/Image/Light_Open_24.png"));
                lblcomstate.Content = "打开";
                lblcomstate.Foreground = Brushes.Green;
            }
            else
            {
                return;
            }
            IsOpenSystem = true;
            imgSystem.Source = new BitmapImage(new Uri("pack://application:,,,/Image/Light_Open_24.png"));
            lblsystemstate.Content = "打开";
            lblsystemstate.Foreground = Brushes.Green;
            btnControl.IsEnabled = true;
            btn_OpenSystem.IsEnabled = false;
            btn_CloseSystem.IsEnabled = true;
            try
            {
                if (GlobalPara.IsClientFun)
                {
                    if (_host == null)
                    {
                        _host = new ServiceHost(typeof(WcfDuplexMessageService.MessageService));
                        IAsyncResult result = _host.BeginOpen(new AsyncCallback(HostOpenAsync), _host);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " and "+ex.InnerException);
            }
        }
开发者ID:qq5013,项目名称:AGV_Server,代码行数:99,代码来源:MainWindow.xaml.cs

示例7: OnLoad

        public static unsafe int OnLoad(IntPtr vmPtr, IntPtr optionsPtr, IntPtr reserved)
        {
            _loaded = true;

            JavaVM vm = JavaVM.GetOrCreateInstance(new JavaVMHandle(vmPtr));

            string optionsString = null;
            if (optionsPtr != IntPtr.Zero)
                optionsString = ModifiedUTF8Encoding.GetString((byte*)optionsPtr);

            string[] options = new string[0];
            if (optionsString != null)
            {
                options = optionsString.Split(',', ';');
            }

#if false
            // quick test
            GetEnvironmentVersion(vm);

            Action<JavaVM> action = GetEnvironmentVersion;
            IAsyncResult result = action.BeginInvoke(vm, null, null);
            result.AsyncWaitHandle.WaitOne();
#endif

            AppDomain.CurrentDomain.AssemblyResolve += HandleAssemblyResolve;

            if (options.Contains("ShowAgentExceptions", StringComparer.OrdinalIgnoreCase))
            {
                AppDomain.CurrentDomain.FirstChanceException += HandleFirstChanceException;
                AppDomain.CurrentDomain.UnhandledException += HandleUnhandledException;
                //AppDomain.CurrentDomain.ProcessExit += HandleProcessExit;
            }

            if (options.Contains("DisableStatementStepping", StringComparer.OrdinalIgnoreCase))
            {
                JavaVM.DisableStatementStepping = true;
            }

            List<WaitHandle> waitHandles = new List<WaitHandle>();
            Binding binding;

            /*
             * start the wcf services and wait for the client to connect
             */

#if false
            /* IJvmEventsService
             */
            _jvmEventsPublisherHost = new ServiceHost(typeof(JvmEventsPublisher));
            Binding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None)
            {
                ReceiveTimeout = TimeSpan.MaxValue,
                SendTimeout = TimeSpan.MaxValue
            };

            _jvmEventsPublisherHost.AddServiceEndpoint(typeof(IJvmEventsService), binding, "net.pipe://localhost/Tvl.Java.DebugHost/JvmEventsService/");
            IAsyncResult jvmEventsPublisherStartResult = _jvmEventsPublisherHost.BeginOpen(null, null);
            waitHandles.Add(jvmEventsPublisherStartResult.AsyncWaitHandle);

            /* IJvmToolsInterfaceService
             */
            _jvmToolsInterfaceHost = new ServiceHost(typeof(JvmToolsInterfaceService));
            binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None)
            {
                ReceiveTimeout = TimeSpan.MaxValue,
                SendTimeout = TimeSpan.MaxValue
            };

            _jvmToolsInterfaceHost.AddServiceEndpoint(typeof(IJvmToolsInterfaceService), binding, "net.pipe://localhost/Tvl.Java.DebugHost/JvmToolsInterfaceService/");
            IAsyncResult toolsInterfaceStartResult = _jvmToolsInterfaceHost.BeginOpen(null, null);
            waitHandles.Add(toolsInterfaceStartResult.AsyncWaitHandle);

            /* IJvmDebugSessionService
             */
            _jvmDebugSessionHost = new ServiceHost(typeof(JvmDebugSessionService));
            binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None)
            {
                ReceiveTimeout = TimeSpan.MaxValue,
                SendTimeout = TimeSpan.MaxValue
            };

            _jvmDebugSessionHost.AddServiceEndpoint(typeof(IJvmDebugSessionService), binding, "net.pipe://localhost/Tvl.Java.DebugHost/JvmDebugSessionService/");
            IAsyncResult debugSessionStartResult = _jvmDebugSessionHost.BeginOpen(null, null);
            waitHandles.Add(debugSessionStartResult.AsyncWaitHandle);
#endif

            /* IDebugProtocolService
             */
            var debugProtocolService = new DebugProtocolService(vm);
            _debugProtocolHost = new ServiceHost(debugProtocolService);
            binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None)
            {
                MaxReceivedMessageSize = 10 * 1024 * 1024,
                ReceiveTimeout = TimeSpan.MaxValue,
                SendTimeout = TimeSpan.MaxValue
            };

            _debugProtocolHost.AddServiceEndpoint(typeof(IDebugProtocolService), binding, "net.pipe://localhost/Tvl.Java.DebugHost/DebugProtocolService/");
            IAsyncResult debugProtocolStartResult = _debugProtocolHost.BeginOpen(null, null);
//.........这里部分代码省略.........
开发者ID:Kav2018,项目名称:JavaForVS,代码行数:101,代码来源:AgentExports.cs


注:本文中的System.ServiceModel.ServiceHost.BeginOpen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。