473,413 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Why are is Mutex owned when requested not to be

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!
Jul 21 '05 #1
0 1148

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rocky | last post by:
I am using the following piece of code to ensure that my application only runs once, however I have a few questions about it. static Mutex m_Mutex; << in c# I assume that when the methods are...
1
by: Richard Hollis | last post by:
I have a site which is using caching for some frequently used pages. When the page-level cache expires, or is expired by me, the page will get re-rendered to a static HTML file and then shown to...
4
by: jcrouse | last post by:
I have searched this board for an example and also read Cor's link to the Google thread. I have an application with a startup module called mStartup. My application, after compiled is called...
8
by: Chris | last post by:
I have an app that is run periodically using Winsows Scheduled Tasks. Occasionally, the app will still be running by the time the scheduled task rolls around again. I don't want the task...
0
by: Stuart M. Ray | last post by:
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...
4
by: m_palmer45 | last post by:
Hi, I was looking at the code in the standard lib's mutex.py, which is used for queuing function calls. Here is how it lets you acquire a lock: def testandset(self): """Atomic test-and-set --...
3
by: NaeiKinDus | last post by:
Hello, i'm trying to program a thread that would be locked (by a mutex) and that would only be unlocked once that a function (generating data) is done. The purpose is to generate data, and unlock...
11
by: Lamont Sanford | last post by:
Given an object of type Mutex, what method or property should be called to determine if it is currently owned? I could call WaitOne(0,false) -- and if the return value is false, I could deduce...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.