Threading problem

SlashOwnsU

New member
Joined
Jul 24, 2006
Messages
2
Programming Experience
Beginner
hello...

I just started experimenting with threads and sockets on dot net, and was quite happy with it until something unexpected happened
I have something resembling this
VB.NET:
 public class PConn
   public sub run()
      do while(true)
         ...some irrelevant operations
      loop
   end sub
 
    public sub doSomething()
       (empty)
    end sub
 end class
somewhere else I create a PConn object and pass it to a player
when a player tries to operate on the pconn object, the thread is stopped
VB.NET:
 ...
 dim pconn as new PConn
 dim th as new Thread(AddressOf pconn.run)
 th.start
 
 dim p as new Player(pconn)
 ...
 'in class player, somewhere...from this point, the running thread in
 'class PConn stops, even if doSomething() is an empty method
 pconn.doSomething()

any ideas ? is it normal ?
 
I just tried that with your exact example, adding a counter messagebox and thread.sleep in do-loop for verification that actually something is happening. No problems with that here, 'th' thread continued.

Neither do the main thread with the player and the other 'th' thread join at any point that could cause a halt/wait in either one.

You could even do the 'run' method from both threads without them stopping each other. To verfify which one you could for example pass the 'Me' form instance to PConn instance and check its InvokeRequired property at invokation, the main thread returns False, the asynchronous call return True.

To sum it up, what you ask as an isolated case can't be reproduced, no error here, and no clue how something else could cause the stop.

Also, please don't double post. Your other post was deleted.
 
sorry if I double-posted
the forum got mixed up because I tried to post the thread before confirming registration, or sumething like that

anyway, I just wanted to know if it was something about threads I didn't know about...but if it's an isolated case, I just don't see what's causing it
thanks you for the answer

I'll just find myself a way around...it'll be less elegant but it should work
 
Back
Top