Page 1 of 1

Posted: Wed Mar 13, 2002 11:24 am
by BackupUser
Restored from previous forum. Originally posted by Horst Hammer.

I am wondering about the right usage of Threads at the moment.
I created a procedure like this:

Code: Select all

;-------------------------------------------
; The Main Loop for NetworkEvents
;-------------------------------------------
Procedure NetworkHandler(dummy)
  Repeat
    NetEvent = NetworkClientEvent()

    NetEvent = 0 
  Until ForEver
EndProcedure
 
and before I call the WaitWindowEvent loop I start to create a thread like this:

Code: Select all

CreateThread(@NetworkHandler,0) 
If I extract this code to and compile the application exits without staring the thread.
If I add it to my current app it crashes.

Anyone having an idea, what my mistake is?

Posted: Wed Mar 13, 2002 1:43 pm
by BackupUser
Restored from previous forum. Originally posted by tranquil.

Hi, possible it works with brackets after the procedurename:

id=CreateThread(@NetworkHandler(),0)

That is what the manual says.
by the way, you thread will run as fast as possible on every machine, that means that it takes 100% CPU usage to check for a networkclientevent.
This is not the right way! You can WAIT for a networkevent by using the
WSAAsyncSelect_ API Command.

If you need help with this, let me know. That is what I made in our app with success and the CPU Usage is under 1% :)

Cheers

Mike

Tranquilizer/ Secretly!
Registred PureBasic User