RE: file i/o in multithreaded apps
- From: stcheng@xxxxxxxxxxxxxxxxxxxx (Steven Cheng [MSFT])
- Date: Tue, 08 Apr 2008 04:33:18 GMT
Hi Mark,
I agree with Pete that the code here looks quite simple and reasonable
which should work well. For the data that got lost, are they written in
some other particular threads which may has some other synchronizing
operations that may cause it to block or not writing correctly? It would be
helpful, if we can simplify it and track down what kind of data are always
lost. BTW, as Pete mentioned, you'd better not lock on the streamwriter
objecct, but use a simple Object member.
Please feel free to post here if there is anything else you found.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
This posting is provided "AS IS" with no warranties, and confers no rights.
-----------------------------
From: =?Utf-8?B?TWFyaw==?= <mmodrall@xxxxxxxxxxxxx>
Subject: file i/o in multithreaded apps
Date: Mon, 7 Apr 2008 14:54:03 -0700
Hi...logger
I've got an app that's pretty multi-threaded. While I'm debugging, I'm
trying to write a log file of events that happen, so I've got a global
that hasthreads
g_LogFileWriter = new StreamWriter(new FileStream(file, Append, Write.
Share.Read);
void Log2File(string format, params object[] arg)
{
lock (g_LogFileWriter)
{
g_LogFileWriter.WriteLine(format, arg);
g_LogFileWriter.Flush();
}
}
Problem is that when things happen very close together and multiple
call this, lines seem to be getting lost. Is there some timing limit onhow
tight many threads can write to the same file stream?
Thanks
Mark
.
- Follow-Ups:
- RE: file i/o in multithreaded apps
- From: Mark
- RE: file i/o in multithreaded apps
- References:
- file i/o in multithreaded apps
- From: Mark
- file i/o in multithreaded apps
- Prev by Date: nettiers and gridview
- Next by Date: Re: Extension Methods in .NET - A Comment
- Previous by thread: Re: file i/o in multithreaded apps
- Next by thread: RE: file i/o in multithreaded apps
- Index(es):
Relevant Pages
|