Seperating Threads in VB

Started by
4 comments, last by Juz 21 years, 7 months ago
Greetings, I''m hoping you can all be of assistance to me... Recently I''ve been dabbling in Dirext8, Winsock, and VB. As you may have guessed, this combo has lead to a simple 3d online ''game'' in which players can run around a small area. This is all fine and dandy, but I''ve noticed a very annoying problem creeping up on my as my network traffic increases to allow for more and more interaction. My network code and render code don''t seem to like eachother. While the programming is rendering a frame, the networking code does not download new packets sent from the server. Instead, it waits until the frame is done before recieving and processing, which leads to one player seeing the others moving around either very choppily or very quickly. The funny thing is, though, that this only happens when the application is active. Once it''s running in the background (and still rendering), the networking code and render code get along peachy, and others players zip around just fine. After talking with a C++ programming friend of mine, he''s suggested that I ''seperate the threads'' so that my rendering pipeline and network code are on seperate threads, however, I''m not sure how I''d do this... So therein is my problem, and I''m seeking a solution - any solution - that you can offer. Thanks in advance, - Juz PS. Here''s a screenshot of a recent build, just for kicks: http://www.swgalaxies.net/test/jmud_multi2.jpg . The little arrow boxes are players.
Advertisement
VB 6 is not thread safe - you can manually create threads (ask in the MS support newsgroups for this), but a lot of operations using VB intrinsic functionality will crash when used by more than one thread.

Thats the price you pay for using a RAD language instead of a lower level language.

You can, though, go to VB.NET - this does not have this problems.


Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)
RegardsThomas TomiczekTHONA Consulting Ltd.(Microsoft MVP C#/.NET)
Hey Juz. I just wanted to say that I recognize you from swgalaxies.net. Can I have your autograph.

------------------------------
p.s. excuse me english. im from L.A.
I think you may be able to get it to work by separating threads into separate ActiveX objects. With that said, I hate ActiveX and never use it, so I''m hardly an expert

Trying is the first step towards failure.
Trying is the first step towards failure.
How is your game loop setup? I overcame this problem with some strategically placed "Do Events" in the draw loop which allowed for the socket reading events. Also your not using the horrible Microsoft Winsock Control are you? (just in case you are you should definetely make the switch to the Catalyst Socketwrench here)


[edited by - Brandisco on September 16, 2002 10:18:06 AM]
I would suggest using DirectPlay, as it will handle the threading issues for you. It is easy to use and works in VB quite nicely.
Don't be afraid to be yourself. Nobody else ever will be.

This topic is closed to new replies.

Advertisement