由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
DotNet版 - easy question, but ...
相关主题
Threading QuestionIs there WinThread in C#
新手问个问题哈,关于C#的如何在C#环境下启动一个新的进程
Windows filesystem bug如何同步多个程序同时读取一个文件
.Net Thread questionWebClient is not thread-safe!
Brainbench .NET有人做过么?7 free ebooks
Quick QuestionThread.Sleep is a sign of a poorly designed program
Thread suspend and resume请问.Net相关的工作,面试是什么风格的?
WebClient for multi-connections?Re: 又开始认证了SQL 2012 (转载)
相关话题的讨论汇总
话题: write话题: would话题: slogfile话题: many
进入DotNet版参与讨论
1 (共1页)
c*o
发帖数: 70
1
Many users will write to the same logfile, how can I make sure there is no
conflict when there are some concurrent access? I can't find a method to check
if the file is open or not.
Would you please add some sample code based on the following code? Thank you
so much!
StreamWriter sw=File.AppendText (sLogFile);
sw.WriteLine (DateTime.Now.ToLongTimeString ()+" "+sText);
sw.Flush ();
sw.Close ();
k****i
发帖数: 1072
2
when you create or open the file

check

【在 c*o 的大作中提到】
: Many users will write to the same logfile, how can I make sure there is no
: conflict when there are some concurrent access? I can't find a method to check
: if the file is open or not.
: Would you please add some sample code based on the following code? Thank you
: so much!
: StreamWriter sw=File.AppendText (sLogFile);
: sw.WriteLine (DateTime.Now.ToLongTimeString ()+" "+sText);
: sw.Flush ();
: sw.Close ();

e*********s
发帖数: 200
3
open it exclusively for write;
or creating a reader/writer threading model to handle concurrency conflicts...
this is a very typical situation

check

【在 c*o 的大作中提到】
: Many users will write to the same logfile, how can I make sure there is no
: conflict when there are some concurrent access? I can't find a method to check
: if the file is open or not.
: Would you please add some sample code based on the following code? Thank you
: so much!
: StreamWriter sw=File.AppendText (sLogFile);
: sw.WriteLine (DateTime.Now.ToLongTimeString ()+" "+sText);
: sw.Flush ();
: sw.Close ();

G**T
发帖数: 388
4

conflicts...
hehe,
VB .NET has eventlog class, u can use it to write system log or ur own log
files.
you

【在 e*********s 的大作中提到】
: open it exclusively for write;
: or creating a reader/writer threading model to handle concurrency conflicts...
: this is a very typical situation
:
: check

1 (共1页)
进入DotNet版参与讨论
相关主题
Re: 又开始认证了SQL 2012 (转载)Brainbench .NET有人做过么?
c#怎么测试deadlock, race condition啊? (转载) Quick Question
怎么学multithreading/concurrency?Thread suspend and resume
multithread app的design要注意哪些问题?WebClient for multi-connections?
Threading QuestionIs there WinThread in C#
新手问个问题哈,关于C#的如何在C#环境下启动一个新的进程
Windows filesystem bug如何同步多个程序同时读取一个文件
.Net Thread questionWebClient is not thread-safe!
相关话题的讨论汇总
话题: write话题: would话题: slogfile话题: many