![]() |
|
[.NET] Thread for each listbox item. Need help asap! [UNSOLVED] - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] Thread for each listbox item. Need help asap! [UNSOLVED] (/showthread.php?tid=5076600) |
Thread for each listbox item. Need help asap! [UNSOLVED] - Mr. Money™ - Nov 30, 2015 Well i want to create a new thread for each listbox item how can i do this correctly? * - thegodhello - Nov 30, 2015 Code Dim dictThread as new Dictionary(of String, Thread)Create a dictionary, change i integer to the amount of listbox items. Code For Each t as Thread in dictThread.ValuesAnd start them. * - Odus - Nov 30, 2015 (Nov 30, 2015 06:19 AM)Luxe Wrote: Create a dictionary, change i integer to the amount of listbox items. Or just cast them to whatever type, loop through each and pass as object to whatever method. * - Mr. Money™ - Nov 30, 2015 Hmm thanks for this i will go read this code couple of times to fully understand it :) For more info about help i need check my other thread. https://hackforums.net/showthread.php?tid=5077076 Still needing help though! * - Mr. Money™ - Dec 1, 2015 Still need help with this! Check the thread link i provided in my previous reply for more info! * - thegodhello - Dec 1, 2015 (Dec 1, 2015 10:06 AM)Reddington™ Wrote: Still need help with this! Replied to your private message. 🤝 * - Mr. Money™ - Dec 1, 2015 I will try what you guys pmed me haha thanks for the help so far will update if it works or nah! edit: Luxe i pmed you back regarding your pm. Update: This is the code i use to get each list item in a seperate thread. But this code sends only the first listbox item through multiple threads what did i wrong? Code try* - hankaf - Dec 2, 2015 You people are making things too complicated for him. This is all you need: Code For i As Integer = 0 To ListBox1.Items.Count - 1* - Mr. Money™ - Dec 3, 2015 Now it starting to work but is opening 1000s of threads for first listbox item. Any idea how to fix that? Code For i As Integer = 0 To ListBox1.Items.Count()* - Jackie Chun - Dec 3, 2015 Put For Each Item outside the dictThread, you're adding a new thread For the entire Listbox count. I think you need to define the structure in which you are using which is the Items in the listbox not the count. Code For Each item In ListBox1.Itemsshouldnt this work? * - Mr. Money™ - Dec 3, 2015 (Dec 3, 2015 02:36 AM)Jackie Chun Wrote: Put For Each Item outside the dictThread, you're adding a new thread For the entire Listbox count. I think you need to define the structure in which you are using which is the Items in the listbox not the count. no, now it gives error that there is a item with the same key with its given name. Any idea how to solve it? Code Dim dictThread As New Dictionary(Of String, Thread)
* - poopGod - Dec 3, 2015 (Dec 3, 2015 04:03 AM)Reddington™ Wrote: no, now it gives error that there is a item with the same key with its given name. Any idea how to solve it?You want to start the thread before it is even added to the dictionary. Put the "dictThread(i).Start()" outside of the nested sub. And why put 2 for loops in each other? You only need 1 of those... And you dont have to explicitly call .ToString on an Integer in VB.net. EDIT: Just do this: Code Dim dicTrd As New Dictionary(Of String, Thread)* - Odus - Dec 3, 2015 Can I ask why everyone is recommending dictionaries to monitor threads? OP said he's checking accounts. It's a short operation so ThreadPool is perfect. |