B
Brian Hampson
I'm new to getting multi-threading working in C#, so I'm looking for
some help with Mutexes.
I have code that looks like the following:
Mutex MyMutex = new Mutex();
Then later in parts that I want to make sure work at separate times:
void Part1()
{
MyMutex.WaitOne();
{//Do Stuff}
MyMutex.ReleaseMutex();
}
void Part2()
{
myTimer.Stop();
MyMutex.WaitOne();
{//Do other stuff that must be not at the saame time as Part1}
MyMutex.ReleaseMutex();
myTimer.Start();
}
Should this work? Part1 is triggered via a FileSystemWatcher and Part2
is triggered via a timer tick.
some help with Mutexes.
I have code that looks like the following:
Mutex MyMutex = new Mutex();
Then later in parts that I want to make sure work at separate times:
void Part1()
{
MyMutex.WaitOne();
{//Do Stuff}
MyMutex.ReleaseMutex();
}
void Part2()
{
myTimer.Stop();
MyMutex.WaitOne();
{//Do other stuff that must be not at the saame time as Part1}
MyMutex.ReleaseMutex();
myTimer.Start();
}
Should this work? Part1 is triggered via a FileSystemWatcher and Part2
is triggered via a timer tick.