0
계약 :net.pipe 서비스 호스트
[ServiceContract]
public interface IDaemonService {
[OperationContract]
void SendNotification(DaemonNotification notification);
}
서비스 : WPF 응용 프로그램에서
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class DaemonService : IDaemonService {
public DaemonService() {
}
public void SendNotification(DaemonNotification notification) {
App.NotificationWindow.Notify(notification);
}
}
나는 다음을 수행하십시오
using (host = new ServiceHost(typeof (DaemonService), new[] {new Uri("net.pipe://localhost")})) {
host.AddServiceEndpoint(typeof (IDaemonService), new NetNamedPipeBinding(), "AkmDaemon");
host.Open();
}
이 WPF 응용 프로그램 출시 다른 앱 :
Task.Factory.StartNew(() => {
var tpm = new Process { StartInfo = { FileName = "TPM" } };
tpm.Start();
}
});
TPM이라는 응용 프로그램이 제대로 시작됩니다. 그런 다음 Visual Studio의 디버깅 메뉴에서 프로세스에 연결하면 클라이언트가 아무도 끝점에서 수신 대기 중임을 알 수 있습니다. ... 당신은 using
에 ServiceHost를을 만드는
오, 나는 피곤했다. :) – EngineerSpock