I noticed that in your method, you aren't closing the StreamWriter with .Close method after writing. That means you are leaving it open for the garbage collector to finalize and close the file which could lead to intermittent blocking.
"using" is sugar for try/finally for objects that implement `IDisposable`
Code:
using (StreamWriter sw = File.CreateText(filepath))
{
sw.WriteLine(message);
}
results it the following intermediate code
Code:
StreamWriter sw = File.CreateText(filepath)
try
{
sw.WriteLine(message);
}
finally
{
sw.Dispose();
}