How to Tell When execution has completed

Advertisement

achiku911
Joined:
Posts:
6

How to Tell When execution has completed

Using Vb.net and wanted to know when I execute a session, how can I tell if that session has completed before I move on to my next session? Currently, it seems like it is launching one sessions and moving to another session. That is making my command collide.

Also, I think because it stays in the same spot for awhile, the execution session may think it is done? What I am executing is a database reindex and since a database maybe large, the command doesn't move for maybe 10 - 15 minutes.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
Location:
Prague, Czechia

Re: How to Tell When execution has completed

Can you show your code. I do not understand the problem. The assembly interface is synchronous.

Reply with quote

achiku911
Joined:
Posts:
6

Re: How to Tell When execution has completed

martin wrote:

Can you show your code. I do not understand the problem. The assembly interface is synchronous.


Below is the routine "ReindexDB" that I call from my code to reindex different databases. So, I have 5 different databases that I call one at a time, hoping the current one finishes before the next reindex starts. Some of these databases are big and for some reason it calls the next one before the other one is done. All I want to ensure is how I can check to see if the process is complete before the next one starts.


Public Sub ReindexDB()
Dim mySessionOptions As New SessionOptions
Dim strHostKey As String = ""
Dim strReindexPath As String = "cd /opt/IBM/JazzTeamServer_" & strJazzVersion & "/server; "
Dim strTime As DateTime = DateTime.Now
Dim strNow As String = "MMMM, dddd d, yyyy HH:mm"

frmMain.lblStatus.Text = strHeader + strStatus + "..."
frmMain.lblStatus.Refresh()

If strStatus = strCLMName Then strHostKey = strCLM
If strStatus = strRTCDevName Then strHostKey = strRTCDev
If strStatus = strCCM2Name Then strHostKey = strCCM2
If strStatus = strCCM2DevName Then strHostKey = strCCM2Dev

With mySessionOptions
.Protocol = Protocol.Scp
.HostName = strStatus
.UserName = strUserName
.Password = frmMain.txtPassword.Text
.SshHostKeyFingerprint = strHostKey
End With

Using mySession As Session = New Session
mySessionOptions.AddRawSettings("Shell", "pbrun su - vobadm")
mySession.Open(mySessionOptions)

Dim dumpCommand As String = String.Format(strReindexPath + strRunCommand + " >" + strDumpPath + "DB_Reindex/" + strStatus + strLogFile)
mySession.ExecuteCommand(dumpCommand)

strAttachment = strLogPath + "DB_Reindex/" + strStatus + strLogFile
End Using

frmMain.dgvInfo.Rows.Add(strHeader + strStatus + " @ " + strTime.ToString(strNow))
frmMain.dgvInfo.Rows.Add(" ")

For Each line As String In System.IO.File.ReadAllLines(strLogPath + "DB_Reindex/" + strStatus + strLogFile)
frmMain.dgvInfo.Rows.Add(line)
Next

frmMain.dgvInfo.Rows.Add(" ")

frmMain.dgvInfo.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
frmMain.dgvInfo.AutoResizeColumns()
End Sub

Reply with quote

martin
Site Admin
martin avatar

Re: How to Tell When execution has completed

Again, the assembly interface is synchronous, including Session.ExecuteCommand. So it won't exit until the command finishes.

Reply with quote

achiku911
Joined:
Posts:
6

Re: How to Tell When execution has completed

martin wrote:

Again, the assembly interface is synchronous, including Session.ExecuteCommand. So it won't exit until the command finishes.

That is not what is happening. The command completes and it moves to another new session while I can see the PID of the previous process still active.

The reason I noticed is the database cannot index on two process at the same time. I get an error message that the previous index has not yet completed.

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Re: How to Tell When execution has completed

What PID? Of a local WinSCP process or remote "database update" process? If the latter, than it's because your command spawns a child process that continues to run asynchronously. That's something WinSCP cannot control. You have to ensure the parent command does not exit before the actual (child) process.

Reply with quote

Advertisement

You can post new topics in this forum