none
How to stop second program? RRS feed

  • Question

  • Hi Expert,

          I worte window service program with VB.Net. My program has two part. One is service program (vb.net) and another is simple program (vb). My problem is second program is stay running when i put "End" function. So How to close that program. What wrong in my code? Second Program is never close.

    VB.Net
    Protected Overrides Sub OnStart(ByVal args() As String)
            ' Add code here to start your service. This method sarrhould set things
            ' in motion so your service can do its work.
            Dim clsEventLog As New EventLogs
            clsEventLog.CreatEvent("Import", "Import Service")
            clsEventLog.WriteEventLog("Import Service", "Service is started at " & Now.ToString, EventLogEntryType.Information)
            clsEventLog = Nothing
            
            Call ReadSettings()
            tTimer = New Timers.Timer(InterVal)
            AddHandler tTimer.Elapsed, AddressOf TimerFired
            With tTimer
                .AutoReset = True
                .Enabled = True
                .Start()
            End With
            
        End Sub
    
    Private Sub TimerFired(ByVal sender As Object, ByVal e As Timers.ElapsedEventArgs)
            Scheduling()
    End Sub
    
    Private Sub RunTask()
    
            Dim clsEventLog As New EventLogs
            Dim psInfo As New ProcessStartInfo
            Dim psProcesss As Process
    
            If gchkTemplateOrder Then
                psInfo.WindowStyle = ProcessWindowStyle.Normal
                psInfo.FileName = "c:\project1.exe"
                psInfo.Arguments = "-hi"
                psInfo.UseShellExecute = True
                psProcesss = Process.Start(psInfo)
                Threading.Thread.Sleep(5000)
                psProcesss.Refresh()
                If Process.HasExited Then
                    psProcesss.CloseMainWindow()
                    psProcesss.Close()
                End If
    End Sub
    
    VB
    
    Form Load Event
            -- Write to file
            End
    End Sub
    

    Tuesday, June 9, 2009 6:25 AM