Multi threading a function?

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
2 posts Page 1 of 1
Contributors
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

Multi threading a function?
AnoPem
Hi i was wondering if it is possible to multi thread a function, im running this function to download files from a website so the function will look like this. the problem is i run this function many times and it will make the program be unusuable while its downloading
Code: Select all
Public Function download(ByVal URL, ByVal fileName, ByVal downloadPath)
'Download code here
end Function
When trying to do it as i usually would i get this
Code: Select all
Error	2	'AddressOf' operand must be the name of a method (without parentheses).	path\Form1.vb	52	72	program
Last edited by AnoPem on Sun Feb 08, 2015 5:45 pm, edited 1 time in total.
https://t.me/pump_upp
User avatar
KraZy
Top Poster
Top Poster
Posts: 93
Joined: Sat May 26, 2012 8:40 am

Re: Multi threading a function?
KraZy
You want insert a thread for this function?
Code: Select all
Imports System.Threading

Dim Update_Job As Thread

Update_Job = New Thread(Sub() download(url,fileName,downloadPath)
Update_Job.Start()

also
Code: Select all
Imports System.Threading

ThreadPool.QueueUserWorkItem(Sub() download(url,fileName,downloadPath))
UPDATE: I see now your edit, use Sub() instead of AddressOf
I'm in the empire business.
2 posts Page 1 of 1
Return to “Coding Help & Support”