all groups > visual studio .net enterprise tools > january 2004 >
You're in the

visual studio .net enterprise tools

group:

EIF text file custom event sink



EIF text file custom event sink Kristen
1/28/2004 8:01:08 AM
visual studio .net enterprise tools: I have a custom event sink that writes to a text file (code borrowed from this message board). In my small, simple test harness, it works fine. However, the call to StreamWriter.close() is not made until the dispose method. Therefore, nothing is actually written to the file until my application stops running.
My question is, if I plug this into a real app, particularly a service, will we never be able to view the contents of the file until the service is stopped? Should I move the close() call to the Write method of the event sink? And if I do that, am I going to cause even more contention/synchronization issues?
RE: EIF text file custom event sink mikehayt_ NO[at]SPAM online.microsoft.com
2/3/2004 6:22:21 PM
Hi there

You could investigate the Stream.AutoFlush property and Stream.Flush()
method to flush the output sooner.

On the FileStream constructor there is a FileShare parameter that you could
use to allow multiple sinks to write to the same file. Of course, this
doesnt stop the synchronization issues. On the whole it would probably be
easy for each sink to write to different files.

Hope this helps

Mike


--------------------
|
| I have a custom event sink that writes to a text file (code borrowed from
this message board). In my small, simple test harness, it works fine.
However, the call to StreamWriter.close() is not made until the dispose
method. Therefore, nothing is actually written to the file until my
application stops running.
My question is, if I plug this into a real app, particularly a service,
will we never be able to view the contents of the file until the service is
stopped? Should I move the close() call to the Write method of the event
sink? And if I do that, am I going to cause even more
contention/synchronization issues?
My sink is very simple right now and does not have code to deal with
syncrhonization issues at all so if anyone has any tips on how I can go
about finding out how to do that too, that would be helpful. For now every
app will probalby write to it's own file, but I can see wanting to support
multiple related apps being able to write to the same text file.
|

--

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
AddThis Social Bookmark Button