See, it's no problem in itself to share a handle. It can cause problems if
you do things to it simoultaneously, however. For example, if 3 threads
want to append data to a file in the same time, it's highly likely that the
file gets corrupted, but if the same three ensure that when one of them is
using the handle, the other two wait for its completion, then nothing will
go wrong.
Well I don't know how thread A can wait on thread B's IO to complete when he doesn't know what thread B is doing...
I've seen two basic schools of thought here. (1) You share the file handle across the thread and have a sync object (crit section) that you lock before writing and unlock when done. (2) you have a worker thread that you post messages to that contains the data to be written. There is no locking that you have to do (but the message queue obviously has locks at the kernel level) and your threads don't get stuck waiting on an IO to complete, which is the longest wait any system has. To me this is a much better solution.
_______________________________________________ msvc mailing list [email protected] See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription changes, and list archive.
