Archived

This topic is now archived and is closed to further replies.

Marc SRS

Free Threading in VB

Recommended Posts

Marc SRS    122
I''m trying to get some basic free multithreading into a VB app with some code that I know works in VB5.. VB6 acts very strangely when run in the IDE, and just GPFs when compiled. Here''s the gist of the code (the Init method from the CThread class): Public Sub Initialize(ByVal lpfnBasFunc As Long) Dim lStackSize As Long, lCreationFlags As Long, lpThreadId As Long, lNull As Long On Error Resume Next lNull = 0 lStackSize = 0 lCreationFlags = CREATE_SUSPENDED uThread.Handle = CreateThread(lNull, lStackSize, lpfnBasFunc, lNull, lCreationFlags, lpThreadId) If uThread.Handle = lNull Then MsgBox "Create thread failed!" End If #If DEBUG_BUILD Then AddLogEntry "Thread creation: " & uThread.Handle #End If End Sub I call this method with: Dim DPThread as new CThread DPThread.Initialize (AddressOf DPLoop) DPThread.Enabled = True '' PLet that resumes the thread DPLoop is a method in a general module that contains a Do...Loop which checks for the availability of DirectPlay messages. It executes fine in the IDE (with some shaky thread exiting), but when I compile it, like I said, GPFville, thread never gets created. Anyone have any clue? Thanks, Marc SiliconReality Software http://www.blackenfall.org

Share this post


Link to post
Share on other sites
TPH    122
Visual Basic 6 does not allow you to create threads. It was sort of ok for VB5 (if you''re careful), but Microsoft have stopped it now.

Share this post


Link to post
Share on other sites
Marc SRS    122
MS''s VB people are such nice guys.. "Hey, we don''t think they should use this feature in their apps. Let''s totally disallow them from doing it." Heh, oh well, there''s always apartment threading until VB.NET arrives..

Marc
SiliconReality Software
http://www.blackenfall.org

Share this post


Link to post
Share on other sites