My case is I have the following method that uses SyncLock to ensure the writing of file by one thread at a time.
Private Shared lockThis As New Object
Public Sub Process()
SyncLock lockThis
File.AppendAllText("c:\jamo\foo.txt","foo")
End SyncLock
End Sub
I'm using many threads running at time:
Public Sub CreateThreads()
Dim trd as Thread
Dim X as Integer = 10
For i as integer = 1 to X
trd = New Thread(AddressOf Process)
trd.Start()
Next Sub
End Sub
My problem is when X is big (like 500), one o more threads write to file at same time. Why is happening this?