vb.net - Program's old processes stay when ftp is offline -


i have program restarts once in while. program uses timer starts thread uploads files folder ftp server. when ftp server goes down, program still restarts needed, old process doesn't close , stays in task manager. when ftp comes up, starts end processes.

this problem doesn't occur when ftp server online.

what causing processes stay when ftp server offline?

to restart program use application.restart()

current code:

public sub uploadtoftp()     dim request = directcast(webrequest.create(ftpadress), ftpwebrequest)     request.credentials = new networkcredential(_username, _password)     request.method = webrequestmethods.ftp.listdirectory     try         using response ftpwebresponse = directcast(request.getresponse(), ftpwebresponse)             try                 dim _frompath string                 dim _topath string                 dim dt new datatable                 dim flag boolean = false                  'create link ftpserver                 dim ftp new ftpclient(_hostname, _username, _password)                 dim _dir new directoryinfo(sourcedir)                 ' upload multiple files                 each _file fileinfo in _dir.getfiles("*.*")                     _frompath = sourcetxt + _file.name                     _topath = "/uploadeddata /" + _file.name                     'upload file                     flag = ftp.upload(_frompath, _topath)                     '' file uploaded delete                     if flag                         _file.delete()                     end if                 next             catch ex exception             end try         end using     catch ex webexception         dim response ftpwebresponse = directcast(ex.response, ftpwebresponse)         'does not exist         if response.statuscode = ftpstatuscode.actionnottakenfileunavailable         end if     end try end sub  private sub timer1_tick(sender object, e eventargs) handles timer1.tick     ftpup = new system.threading.thread(addressof uploadtoftp)     ftpup.priority = threadpriority.abovenormal     ftpup.start() end sub 

try using ftpup.isbackground = true makes thread belong app , should close app closes.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -