Sinisterly
Multi Thread - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Visual Basic & .NET Framework (https://sinister.ly/Forum-Visual-Basic-NET-Framework)
+--- Thread: Multi Thread (/Thread-Multi-Thread)



Multi Thread - LethalNET - 07-30-2013

Greetings CM members, Today I'm gonna show you how to easily multi-thread your applications to prevent annoying crashing.

Step 1 :
Make a new Console Application and Import threading into the project
PHP Code:
Imports System.Threading
Step 2:
Declare a new thread to handle a sub/function, I will be using a simple tick/counter
Sub Main Load:
PHP Code:
Dim T1 As New Thread(Sub() Example()) T1.Start()
Counter Class:
PHP Code:
Sub Example() For i = 0 To 10 Threading.Thread.Sleep(1000) Console.WriteLine(i) Next End Sub

And thats it! If you have a line which uses a + or * or / symbol than use this:
PHP Code:
Me.Invoke(DirectCast(Sub() i = i + 0, MethodInvoker))
Or else a you will get a threading error.

Enjoy Biggrin