TextWriter synchronized method

  • Thread starter Thread starter fniles
  • Start date Start date
F

fniles

If I use TextWriter synchronized method like below codes if another thread
is trying to write at the same time, what will happen ? Will it the 2nd
thread request to write to the file be queued ? Will the 2nd thread then
stop processing other codes while waiting to write to this file ?

Thank you.

Dim swLogOrig As StreamWriter
Dim swLog As TextWriter

swLogOrig = New StreamWriter(m_sLogFileName, True)
swLog = TextWriter.Synchronized(swLogOrig)
 
If I use TextWriter synchronized method like below codes if another
thread is trying to write at the same time, what will happen ?

I believe it will block until the first thread releases the write.


Synchronized methods implement a simple synclock mechanism if I'm not
mistaken.
 
so if you use the sychronized, you don't have to lock?
will it automatically queue the next calls for that specific textwriter?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

StreamWriter Write error in thread 1
Error writing to a file 3
Thread safe TextWriter question 3
Thread issue 4
Opening files for output 2
TextWriter Question 5
Problem With TextWriter 2
Re-declare?? 5

Back
Top