I created some FTP routine as part of a Visual Basic application that calls WinSCP three times during runtime.
Every time a call to WinSCP is initiated via the WinSCPnet.dll a new "WinSPC.exe" process pops up connected to my application (i.e. as child processes).
I would have expected that a single process would pop up, or at least that every call would re-use the existing process.
What makes things worse is that at the moment my application stops the "WinSCP.exe" processes keeps on running...
Looking for a way to prevent this from happening, I don't like the idea of multiple ghost processes in memory...
Added the close method to the tool, now only one ghost "WinSCP.exe" remains in memory... still not the solution I look for.
Dispose method results in the same as the close method... every time my application closes a single "WinSCP.exe" process remains in memory, so after ten runs the process is there 10 times...
Finally added the following VB code to find and kill WinSCP.exe processes started by my application:
Dim myId = Process.GetCurrentProcess.Id
Dim selectQuery As SelectQuery = New SelectQuery("Win32_Process", "Name = 'WinSCP.exe'")
Dim searcher As New ManagementObjectSearcher(selectQuery)
For Each proc As ManagementObject In searcher.Get
If (proc("ParentProcessId") = myId) And (proc("name") = "WinSCP.exe") Then Process.GetProcessById(proc("ProcessId")).Kill()
Thanks for the suggestion... helped me to find the cause for the "ghost"...
I added the "dispose" to the session I used to update data... however I forgot to add it to a second session which I used to check the initial state of a remote folder... :-(
So I added the dispose there as well and now the ghost process also disappears!
(I was able to get 2 log files where I expected to get 3 by adding the microseconds to the logfile)