Winsock and Multithreading 
Author Message
 Winsock and Multithreading

I'm using the winsock control on one of my VB6 forms.  From doing tests it
seems like when the winsock dataarrival event handler is fired after
receiving some data, the event handler is run in a thread different than
the main application thread.  Do I have to do something like subclassing a
form in order for the code to run in the main application thread instead
of the separate thread?


Tue, 17 May 2005 00:22:29 GMT  
 Winsock and Multithreading

Quote:
>I'm using the winsock control on one of my VB6 forms.  From doing tests it
>seems like when the winsock dataarrival event handler is fired after
>receiving some data, the event handler is run in a thread different than
>the main application thread.  Do I have to do something like subclassing a
>form in order for the code to run in the main application thread instead
>of the separate thread?

It does appear to use a separate thread (probably for callbacks), but
regardless of how it implements asynchonous operation, it delivers
events in the context of the app's thread (i.e. the same thread as the
host form). Since you can't change the asynchonous behavior or other
internal workings of the control, about all you can do if you want
something different is to use the winsock Api directly instead of the
control.

-Tom
MVP - Visual Basic
(please post replies to the newsgroup)



Tue, 17 May 2005 01:46:07 GMT  
 Winsock and Multithreading
Tom,

Quote:
> Since you can't change the asynchonous behavior or other
> internal workings of the control, about all you can do if you want
> something different is to use the winsock Api directly instead of the
> control.

I suppose an alternative would be to send/post a windows message from within
the event.

Zane Thomas - C# MVP
www.abderaware.com
Internet Components for .NET



Tue, 17 May 2005 02:57:53 GMT  
 Winsock and Multithreading
On Thu, 28 Nov 2002 10:57:53 -0800, "Zane Thomas"

Quote:

>I suppose an alternative would be to send/post a windows message from within
>the event.

Yeah, but I'm assuming the OP's intent is the opposite (i.e. a more
synchronous behavior). That may be assuming too much <g>, but offhand
I can't imagine why else the component's internal use of another
thread would matter.

-Tom
MVP - Visual Basic
(please post replies to the newsgroup)



Tue, 17 May 2005 04:27:48 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Multithreading WINSOCK in VB6

2. R: Multithreading WINSOCK in VB6

3. Winsock (Multithreading)

4. Multithreading a winsock application

5. Multithreading in Access - Is it possible?

6. DAO 3.5 and multithreading --yes or no?

7. Access and multithreading...

8. Multithreading in Com Add in blocks Outlook Event Handlers

9. sockets and multithreading

10. Multithreading

11. Multithreading a new form

12. Multithreading and shared variables

 

 
Powered by phpBB® Forum Software