• Welcome to Valhalla Legends Archive.
 

Running multiple functions all at once. (Multi-threading)

Started by Elneroth, October 13, 2005, 06:29 PM

Previous topic - Next topic

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".
Event TerrainRendering()

Public Sub StartRendering()
RaiseEvent TerrainRendering
End Sub


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

Public Sub clTR_TerrainRendering()
    Msgbox "Test"
End Sub


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.
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


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.

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).