>Are you saying that locking, Seeking, BeginWriteing, and unlocking is
not good enough?

Well, I guess it is good enough, just doesn't seem very elegant.  Would be nice 
if there was an offset in there so one "atomic" call could be made.  Same as 
with Win32 overlapped io.

>Does the BeginWrite not in effect take a snapshot of
the seek location when the operation starts?

I don't know for certain if it does, I certainly hope so.  Time to go digging 
with reflector I guess.

Ian Griffiths <[EMAIL PROTECTED]> wrote:
The documentation says that members of this class are not thread safe,
so multiple threads shouldn't be using this at any given instance. You
need to do some kind of locking if you have multiple threads using it.

Are you saying that locking, Seeking, BeginWriteing, and unlocking is
not good enough? Does the BeginWrite not in effect take a snapshot of
the seek location when the operation starts?


--
Ian Griffiths
http://www.interact-sw.co.uk/iangblog/

> -----Original Message-----
> From: John Davis
>
> The way I understand it, the current BeginWrite on the FileStream
object
> will write out it's buffer at the location of the last Seek. The
problem
> comes when there are multiple threads using the same FileStream
instance.
> Each one is looking to write to a different offset in the file. This
> means each thread must call FileStream.Seek followed by
> FileStream.BeginWrite Obviously, this creates a race condition.
>
> Why isn't there an async BeginWrite, on the FileStream, with an
argument
> which specifies the offset within the file to write to. It's possible
to
> call WriteFileEx within the Win32 API with an OVERLAPPED struct which
> specifies the offset. Why isn't this exposed through the framework?

===================================
This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com


---------------------------------
Do You Yahoo!?
 Yahoo! Small Business - Try our new Resources site!

===================================
This list is hosted by DevelopMentor�  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to