Hack Forums
[.NET] [Newb TuT] How to use muiltithreading {My first tut}[Newb TuT] [Very useful] - 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] [Newb TuT] How to use muiltithreading {My first tut}[Newb TuT] [Very useful] (/showthread.php?tid=1459153)



[Newb TuT] How to use muiltithreading {My first tut}[Newb TuT] [Very useful] - Tim Joe - Jul 7, 2011

Muitithreading


Before I start I'm going to assume you know the basics, such as Imports, classes, Subs, Variables and the syntax of vb. If you don't go here HERE and start going threw the tutorials.

Ok so now on to muiltithreading, you can thank of muiltithreading as multitasking in VB.NET. You can start a sub but still have the other on going. Its A good thing to learn if you want to make a bot, viewer, spammer are anything really.

Step one - Add the controls

Controls (Click to View)

Step two - Add 2 subs

Ok so now I'm going to add two subs, One is going to make my first label count up the other will make the other label count up. To do this your going to make a while loop that make a label go to 10 in each one then pause for 1000 millisec's like so..
Image (Click to View)

Step three - button one (No muiltithreading)

Ok so now you have the 2 subs to count the labels up, now we have to set the 2 buttons, one will muitithread one wont. First go to the one that wont and make it call both of the subs you just made like so..
Image (Click to View)

Step 4 - button two (muiltithreading)

Last but not least we have to and the muitithreading button. This is fairly easy. First import system.threading. next declare 2 threads. After that you set the threads to the address of the sub as show below. You will find when you click the button without muiltithreading it will basically freeze but if you press the other button the labels will count up.
Image (Click to View)

PROFIT!!




* - xXxRay - Jul 7, 2011

Awesome Tut ! Thanks for that .


* - Tim Joe - Jul 7, 2011

(Jul 7, 2011 05:49 PM)xXxRay Wrote:  Awesome Tut ! Thanks for that .

Thanks I spend A good hour on it I just added the photos


* - Deceptive - Jul 7, 2011

Dim T As New System.Threading.Thread(AddressOf SubShit)
T.Start()


* - Fake. - Jul 7, 2011

Why would you create an infinite loop that you must force-close? Bad way to teach beginners..


* - Tim Joe - Jul 7, 2011

(Jul 7, 2011 05:55 PM)TheMist Wrote:  Dim T As New System.Threading.Thread(AddressOf SubShit)
T.Start()

That works two, Ill add that in a sec

(Jul 7, 2011 05:55 PM)Fake™ Wrote:  Why would you create an infinite loop that you must force-close? Bad way to teach beginners..

Changing now, just give me a sec


* - TickTack - Jul 7, 2011

EXTREMELY bad coding habits.

Even if VB does it automatically for you, always convert strings to integers when doing integer work. Going on to other languages like this will result in epic failure.


* - GanjaMan-WS - Jul 8, 2011

Me.CheckForIllegalCroosThreadsCalls = False

(Jul 7, 2011 11:40 PM)TickTack Wrote:  EXTREMELY bad coding habits.

Super EXTREMELY bad coding habits.




* - hgdfhsdgdfgdfh - Jul 8, 2011

Updating GUI from another thread in unsafe way... Use Control.Invoke if you want to update GUI from another thread.


* - RiperFish - Jul 8, 2011

https://hackforums.net/showthread.php?tid=1410154


* - Diabolic - Jul 8, 2011

This looks like a pretty decent tutorial, well done.


* - Shoсkwave - Jul 8, 2011

Thanks for the tut man, am learning multithreading for a booter im making =/