|
-
Aug 4th, 2010, 03:36 PM
#1
Thread Starter
Fanatic Member
Thread safety
I made this client/server application, in which the server uses a thread to listen for clients. All the listening is done within a single-instance class, and all communication to the primary thread is done through events. This all works fine in VB2003, but when exported to VB2010 the events (client message received, connection established etc.) trigger a thread safety exception, due to manipulation of objects outside thread.
The solution to use out-of-thread properties apparently is to use an asynchronous callback or use a background worker and it's completion event.
Neither of these solutions are really appealing, since they both will require a substantial amount of additional coding and the background worker especially isn't feasible (thread supposed to keep running). The programming ought to be thread-safe as is in my opinion, since one thread is raising events only (no manipulation of objects) and the other thread listens for events and reacts to them through function parameters.
1) Is there any way around this problem (using VB2010 that is )?
2) Is my code thread safe as is, or am I missing something?
3) Which of the 2 approaches (background worker or asynchronous callbacks) should I choose, if I decide to make the server thread safe.
Thanks for any inputs
Tom
In truth, a mature man who uses hair-oil, unless medicinally , that man has probably got a quoggy spot in him somewhere. As a general rule, he can't amount to much in his totality. (Melville: Moby Dick)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|