本文整理汇总了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);
}
示例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();
}
}
示例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);
}
示例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);
}
}
}
示例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();
}
示例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);
}
}
示例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);
//.........这里部分代码省略.........