Results 1 to 7 of 7

Thread: Vb Multi-Threading

  1. #1

    Thread Starter
    Addicted Member tonyenkiducx's Avatar
    Join Date
    Oct 2000
    Location
    London England
    Posts
    147

    Talking

    Ohh, dodgy subject I know.. I need to do multi-threading in VB specifically to be able to branch off a function call, and continue on with the rest of my proggie. I need to have a constant execution of this function, but I cant be waiting for a reply back from the function, because it involves the internet and it could be a long wait(Which my program cant wait for because its got other users to serve).

    Tony.C

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    I am become death, the destroyer of worlds.
    mail:vlatkovr@hotmail.com

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3

    Thread Starter
    Addicted Member tonyenkiducx's Avatar
    Join Date
    Oct 2000
    Location
    London England
    Posts
    147

    Talking

    Thanks for that.. unfortunately its as bad as I thought it would be, and dog slow when Ive tried it on a large scale. Ok, Ive got an easier question, anyone want to lend a hand/ear/arm/body part in constructing an online game? Its mostly written Im just trying to optimise it, and VB isnt my strong hand, and Im floundering a little. Mail me at tony@enkidu.cx if your interested..

  4. #4
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    Why not try placing your function in a class module? I've noticed that VB tends to act in a similar way when accessing modules like that, or possibly link your function to an event or some other trickery?
    -Excalibur

  5. #5

    Thread Starter
    Addicted Member tonyenkiducx's Avatar
    Join Date
    Oct 2000
    Location
    London England
    Posts
    147

    Talking

    Well, I tried that, and its how Im currently doing it, Im using a timer to watch a variable change, then making the timer execute a function in a module. This is fast and nice, but imagine this situation, Im executing an array full of outgoing data, I send one, it goes, I send another.......... and theres no response, it takes 10 seconds to call a timeout, and all the other outgoing commands have had to wait for that function to finish. Now the only solution I could think of was to make the timer execute 1 command at a time, thus providing threading, but I didnt know if VB supported real threading, or wether it would just fall on its arse.

    The other question I forgot to ask was, do you have to wait while the winsock object sens something, or do you just tell it what to do, then carry on while it sends the data to the user?

  6. #6
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    I'm also writing a multi-player game in VB and my solution to the threading (and My not knowing how to code it properly) was to spawn each 'user' as its own object with it's own command parser, winsock, etc. Each one operates independently of one another and is pretty fast and fluid. Though I've been working on an event driven model and killing off for next loops as well. (This project is on hold for the time being as I'm working on ZoneWriter, a program that assists in writing AberMUD zones). If you'd like more information on how I'm doing this, go ahead and mail me, I'll share what I can, and give you some ideas on where I'm going with the project.
    -Excalibur

  7. #7

    Thread Starter
    Addicted Member tonyenkiducx's Avatar
    Join Date
    Oct 2000
    Location
    London England
    Posts
    147

    Unhappy

    Thanks for the input, but Ive tried that allready and the winsock really needs to be in one solid object, or its memory size and speed are absolutely silly at higher levels. Plus it doesnt allow for a user losing there connection, you cant really reconnect a user back up to an object once theve lost the connection(Not without much pissing around).

    My current method uses 2 arrays, one with commands that need performing, and one with text that needs sending, each of them using the winsock index number as a user reference. Once either of them changes, a timer copies them, blanks them out, and sends them off to relevant sub to be processed. Ive found this to be the quickest way of performing pseudo-threading in VB, with the only exception that there is no "If Sub.Wait > 500" command, so if a sub takes to long to execute, you cant really kill it(Not in any reliable way)

    Im putting this live on a test server in a few days, and then Ill know wether it does real threading, Ill post the results here.

    In the mean time, does anyone know if Vb waits for commands to the winsock engine to be completed before continuing?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width