Hi All,
The first parameter on the System.Threading.Mutex constructor is a
Boolean called initiallyOwned that, according to the documentation,
will give the calling thread ownership if it is true. This leads me
to believe that if false is specified then the calling thread would
not be given ownership. However, the following code indicates that
the calling thread is granted ownership regardless of the
initiallyOwned parameter value.
bool createdNew;
using(Mutex mutex = new Mutex(
false, COMMON_MUTEX_NAME, out createdNew))
{
// This is surprisingly true since
// the initiallyOwned parameter is false.
Assert.IsTrue(createdNew, "The mutex is not owned initially");
}
By the way, according to the documentation, the createdNew flag
indicates the initial owernship.
"contains a Boolean that is true if the "
"calling thread was granted initial ownership"
"of the mutex; otherwise, false"
In other words, this code indicates that the created Mutex is always
owned by the calling thred regardless of the initiallyOwned parameter
value. Any ideas why?
Thanks!