Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Ok there are 2 ways of writing text to a file in multi threaded system

Which one is better than other

First case : having a static object to lock streamwriter and do operations

Second case having

C#
TextWriter twWaitingToBeFetched;
twWaitingToBeFetched = TextWriter.Synchronized(new StreamWriter(stringPath, true));
twWaitingToBeFetched.WriteLine(srNewComposedUrl);
twWaitingToBeFetched.Flush();



Now which one is better do you think and why ?

I need multiple threads tasks to write same stream

C# .net 4.5 - WPF application
Posted
Comments
Herman<T>.Instance 13-Aug-14 9:55am    
Why not test it yourself?
MonsterMMORPG 13-Aug-14 17:08pm    
I need more experienced developers feedback

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900