[Solved] Streamreader locks file

StreamReader smsmessage = new StreamReader(filePath); try { FileInfo filenameinfo = new FileInfo(filePath); …. smsmessage = filenameinfo.OpenText(); … You are initializing smsmessage twice, but only disposing one of those instances. The first line constructs a StreamReader, and then you overwrite your reference to that instance with the instance created by filenameinfo.OpenText(). That leaves you with an … Read more

[Solved] synchronization object [closed]

What is the advantage of using this type of object to lock? Why would there be an advantage to a specific type of lock object? As the manual states: Best practice is to define a private object to lock on, or a private static object variable to protect data common to all instances. Can I … Read more