I need to build a unique filename in a multithreaded application which is serializing some data on the disk. What approach could I use to ensure a unique name. The app was not multithreaded before and was using Ticks. When using multiple threads, it failed much faster than I expected. I now added the CurrentThreadId to the filename, and that should do it
string.Format("file_{0}_{1}.xml", DateTime.Now.Ticks, Thread.CurrentThread.ManagedThreadId)
Is there any "smarter" way of doing this?