| | |
Thread.suspend and thread.resume is obsolete
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jun 2009
Posts: 271
Reputation:
Solved Threads: 56
Hello
I am coding an FTP program, the downloading/uploading happens in a seperate thread. The problem is now how to pause/resume the download (even on servers that don't support file resume), an easy/working way is to pause/resume the working thread with thread.suspend but it tells me that this function is obsolete.
Is there a simmilar method to achieve this? I've tried looking up Mutexes, Monitor, Event, Semaphore stuff but that would only allow me to pause the file transfer after the file is done.
So the code that 'lives' in the thread that I want to suspend looks something like
Function get called as following:
So UploadThread.suspend() / resume works perfectly, but I can't really release this if these functions get removed in future releases of .net
Any help is appreciated
GeekByChoiCe
I am coding an FTP program, the downloading/uploading happens in a seperate thread. The problem is now how to pause/resume the download (even on servers that don't support file resume), an easy/working way is to pause/resume the working thread with thread.suspend but it tells me that this function is obsolete.
Is there a simmilar method to achieve this? I've tried looking up Mutexes, Monitor, Event, Semaphore stuff but that would only allow me to pause the file transfer after the file is done.
So the code that 'lives' in the thread that I want to suspend looks something like
vb Syntax (Toggle Plain Text)
Private Sub StartUpload(ByVal allFiles As Hashtable) For Each singleFile As String In allFiles.Keys Try ftpClient.UploadFile(singleFile, allFiles.Item(singleFile), False) Catch ex As Exception ftpClient.DeleteFile(allFiles.Item(singleFile)) Exit For End Try Next allFiles = Nothing End Sub
vb Syntax (Toggle Plain Text)
UploadThread = New Threading.Thread(AddressOf StartUpload) UploadThread.Start(allFiles)
So UploadThread.suspend() / resume works perfectly, but I can't really release this if these functions get removed in future releases of .net
Any help is appreciated
GeekByChoiCe
•
•
Join Date: Aug 2008
Posts: 83
Reputation:
Solved Threads: 18
I don't believe that support for these methods will be removed in any future release, for backwards compatability. The reason for it being marked as obsolete is because when suspending a thread, you cannot determine where in the method the thread suspends at. Instead, you should generally use a boolean variable, and have the method check at certain points the value of the variable, and suspend the thread using a while loop or something.
•
•
Join Date: Jun 2009
Posts: 271
Reputation:
Solved Threads: 56
Almost forgot to mark it as solved d'oh
Actually after days of trying i figured out that Thread.Suspend is exactlly what i shouldn't do o.O
When i suspend the FTP Upload it works perfect for exact the time until the FTP server timeouts and disconnect. If i then want to resume my Upload it fails ofc.
Anyway it seems i still have two possibilities:
1. pausing the transfer after the current file is uploaded (if uploading multiple files)
2. saving the count of current transfered bytes and sending the resume command to the ftp server by giving the count as argument. But not all FTP server are set up to support file resume. so guess option 1 wit will be.
Problem solved.
Actually after days of trying i figured out that Thread.Suspend is exactlly what i shouldn't do o.O
When i suspend the FTP Upload it works perfect for exact the time until the FTP server timeouts and disconnect. If i then want to resume my Upload it fails ofc.
Anyway it seems i still have two possibilities:
1. pausing the transfer after the current file is uploaded (if uploading multiple files)
2. saving the count of current transfered bytes and sending the resume command to the ftp server by giving the count as argument. But not all FTP server are set up to support file resume. so guess option 1 wit will be.
Problem solved.
![]() |
Similar Threads
- Terminating a thread in OnDestroy (Pascal and Delphi)
- How do I pause a thread indefinitely? (Java)
- multithreading c++ (C++)
- Hi Help me with Multilevel feedback scheduling (Java)
- vBulletin mod_rewrite (PHP)
- [Revised] vBulletin Mod_rewrite Tutorial (PHP)
- vBulletin mod_rewrite for vB 3.0.7 (Existing Scripts)
Other Threads in the VB.NET Forum
- Previous Thread: how to upload a photo to a form in vb.net
- Next Thread: dropdown
Views: 1207 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2005 2008 access account application array arrays basic browser button buttons center check checkbox code convert crystalreport cuesent data database datagrid datagridview date datetimepicker design designer dissertation dissertations dissertationtopic dropdownlist eclipse excel fade filter ftp generatetags gridview images inline input insert installer intel internet lib listview mobile monitor net objects panel passingparameters pdf picturebox port position print printing problem read remove save searchbox searchvb.net select serial settings shutdown soap sorting studio survey table tcp temperature textbox time timer timespan transparency trim update user validation vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet visual visualbasic visualbasic.net visualstudio2008 web webbrowser winforms wpf year





