Vb.net 我可以在windows服务中使用返回功能吗?

Vb.net 我可以在windows服务中使用返回功能吗?,vb.net,windows-services,Vb.net,Windows Services,我可以在windows服务中使用函数并将数据返回到vb.net应用程序吗 以下是我在windows服务中的示例代码: Protected Overrides Sub OnStart(ByVal args() As String) ' Add code here to start your service. This method should set things ' in motion so your service can do its work.

我可以在windows服务中使用函数并将数据返回到vb.net应用程序吗

以下是我在windows服务中的示例代码:

 Protected Overrides Sub OnStart(ByVal args() As String)
        ' Add code here to start your service. This method should set things
        ' in motion so your service can do its work.
        EventLog1.WriteEntry("In OnStart")
    End Sub

    Protected Overrides Sub OnStop()
        ' Add code here to perform any tear-down necessary to stop your service.
        EventLog1.WriteEntry("In OnStop.")
    End Sub
    Protected Overrides Sub OnContinue()
        EventLog1.WriteEntry("In OnContinue.")
    End Sub
    Protected Overrides Sub OnCustomCommand(ByVal command As Integer)
        Dim mymsg As String
        Dim servicestorun As New System.ServiceProcess.ServiceBase
        If (command < 128) Then
            MyBase.OnCustomCommand(command)
        Else
            Select Case command
                Case 129
                    mymsg = "i want this msg to my vb.net application"
                Case Else
            End Select
        End If

    End Sub
Dim myServiceController As New System.ServiceProcess.ServiceController("MyNewService")

        Dim status As String
        Try
            myServiceController.ExecuteCommand(129)
 ' i want to get the msg from my windows service "i want this msg to my vb.net application"
            status = "Custom Command Executed Successfully!"
        Catch ex As Exception
            status = "Failed To Execute Custom Command! " & ex.Message
        End Try

请寻求帮助。

您可以将windows服务用作WCF主机。例如,见


对于同一台机器上的通信,我建议使用命名管道(NetNamedPipeBinding)。您甚至可以在不使用WCF的情况下使用命名管道(http://stackoverflow.com/questions/4303154/)

您可以将windows服务用作WCF主机。例如,见


对于同一台机器上的通信,我建议使用命名管道(NetNamedPipeBinding)。您甚至可以在不使用WCF的情况下使用命名管道(http://stackoverflow.com/questions/4303154/)

我明白了,谢谢你的回复。。我真的很感激:>,我来试试。我明白了,谢谢你的回复。。我真的很感激:>,我来试试。