So,
Carrying on from my last question on this subject, I thought I had it all licked. All is working fine; I have implemented a locker to stop simultanious access of the disk. I was aware at the time that I had two instances of my object running in their own threads but I now require there to be only one. I will explain..
Here is my useful class that requires to run along in it's own space; I have applied the locker where methods access the disk:-
public class Logger
{
static readonly object locker = new object();
.....
}
Now, instantiate it from class x
_logger = new Logger();
loggerThread = new System.Threading.Thread(new System.Threading.ThreadStart(_logger.Initialise));
loggerThread.Start();
..and again in class y
_logger = new Logger();
loggerThread = new System.Threading.Thread(new System.Threading.ThreadStart(_logger.Initialise));
loggerThread.Start();
All is ok, I use it's properties from each calling class to log to my file, each class identifies who is writing to the file and so no problem. I would however like to maintain the variables from all calling classes so that these are all logged regardless of who is calling the 'log' method..
ie. I would like to instantiate it in one place but have multiple classes able to use it. I'm sure the solution will be obvious to many of you but not me i'm affraid..