-
Incorrect proactive you can you can write multi-threaded apps with VB, it's not an easy thing to do. Some tricky win32 api calls and the endless stream of gpf's allows multi-threading. Additionally the .net architecture will change all that, multi-threading in VB will be a breeze consider the folowing code
Imports System
' Import the threading namespace
Imports System.Threading
Public Class clsMultiThreading
' This is a simple method that runs a loop 5 times
' This method is the one called by the HelloWorldThreadingInVB
' class, on a separate thread.
Public Sub OwnThread()
Dim intCounter as integer
For intCounter = 1 to 5
Console.WriteLine("Inside the class: " & intCounter.ToString())
Next
End Sub
End Class
Public Class HelloWorldThreadingInVB
' This method is executed when this EXE is run
Public Shared Sub Main()
Dim intCounter as integer
' Declare an instance of the class clsMultithreading object
Dim objMT as clsMultiThreading = new clsMultiThreading()
' Declare an instance of the Thread object. This class
' resides in the System.Threading namespace
Dim objNewThread as Thread
'Create a New Thread with the Thread Class and pass
' the address of OwnThread method of clsMultiThreading class
objNewThread = new Thread(new ThreadStart(AddressOf objMT.OwnThread))
' Start a new Thread. This basically calls the OwnThread
' method within the clsMultiThreading class
' It is important to know that this method is called on another
' Thread, as you will see from the output
objNewThread.Start()
' Run a loop and display count
For intCounter = 10 to 15
Console.WriteLine("Inside the Sub Main: " & intCounter.ToString())
Next
End Sub
End Class
now thats alot easier than good old vb6 multi-threading.
-
Interesting. If you by any chance know how to create critical sections (in VC++: entercriticalsection and leavecriticalsection) this would be truly useful in my work. Did a quick search on google but didn't find anything.
Good post V3RIZON!
-
VB is a great first language but by no means should someone limit them selves to just VB.