Re: Filestreams
- From: "Marc Gravell" <marc.gravell@xxxxxxxxx>
- Date: Thu, 11 Jan 2007 08:02:48 -0000
For now I can just leave the stream open and let it dispose of
itself at the end of all things.
I wouldn't trust this approach; firstly, objects *never" dispose
themselves; they may get finalized by the GC, but that is not (quite)
the same thing. In fact, finalizers aren't fully guaranteed to run at
all, let alone at a predictable time. My advice: find a point in your
program where you know you are preparing to exit; explicitely Close()
and Dispose() the stream/writer, presumably by a static Close() method
on the Log class. The other option is to look for existing logging
solutions; they may do everything you need (and more) and abstract
away the complexities, including (possibly) tricks like queueing
writes in a producer/consumer pattern to avoid being IO-bound (just
blocked while enqueing).
In the threaded scenario, yes: you will need locking.
Marc
.
- References:
- Filestreams
- From: Bob Weiner
- Re: Filestreams
- From: Bob Weiner
- Filestreams
- Prev by Date: Re: Opinions on latest AMD and Intel processors, is one better suited for development?
- Next by Date: Re: combobox SelectedIndexChanged event
- Previous by thread: Re: Filestreams
- Next by thread: Re: Custom uninstall process
- Index(es):
Relevant Pages
|