Valhalla Legends Forums Archive | Visual Basic Programming | Running multiple functions all at once. (Multi-threading)

AuthorMessageTime
Elneroth
I was creating a Direct3D/DirectX 8 "Terrain Rendering Function" which loops through every vertex and renders it into Direct3D.. but this takes too long to loop through and I would much rather have it do them all at the same time.

First, I attempted to use two class modules:

The first, labeled (PreTerrains) had a function that would use RaiseEvent to an event labeled "TerrainRendering".
[code]Event TerrainRendering()

Public Sub StartRendering()
RaiseEvent TerrainRendering
End Sub[/code]

The second class, labeled (Terrains) was 'withevents' declared to the first. (Sorry, hard to word it out):
[code]Dim WithEvents clTR As PreTerrains

Public Sub clTR_TerrainRendering()
    Msgbox "Test"
End Sub[/code]

On the main form, I had a couple copies of the second class declared to ensure there were isntances of them able to catch the raisevent call.
[code]Option Explicit
Public cllTR(5) As Terrains
Public cmTR As PreTerrains

Private Sub Form_Load()
Dim intC%
For intC = 0 to 5
Set cllTR(intC) = New Terrains
Next intC

Set cmTR = New PreTerrains
cmTR.StartRendering
End Sub[/code]

The problem is, whenever I tried it, nothing would happen. (I never received a messagebox.)

Any help would be appreciated., or, if you can, explain another way to do multiple copies of a function/functions at once.
October 13, 2005, 11:29 PM
Adron
Unless you have multiple processors or hyperthreading, you are unlikely to see a speed improvement from running those functions at the same time. And the problem with your code would seem to be not assigning anything to cllTR(intC).clTR (and not calling that).
October 14, 2005, 6:14 PM

Search