473,563 Members | 2,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

detecting object lock?

Is there any way knowing if an object is locked, for example, "lock(objec t)
{...}" ?

Please reply. Thanks in advance.

Hyun-jik Bae
Mar 10 '07 #1
1 1461
Hyun-jik Bae wrote:
Is there any way knowing if an object is locked, for example, "lock(objec t)
{...}" ?

Please reply. Thanks in advance.

Hyun-jik Bae
You can use Monitor.TryEnte r(theObject) to try to use the object in a
lock. If it returns false, the object is already used in a lock. If it
returns true, you have successfully used it in a lock.

Note: Using an object in a lock doesn't protect the object in any way,
it only stops any other code to use the same object in a lock.

--
Göran Andersson
_____
http://www.guffa.com
Mar 10 '07 #2

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

Similar topics

5
12511
by: Jole | last post by:
Hi I'm writing a program that needs to read from a file. In order for the program to be robust, it should somehow check that the file isn't corrupt, or stuffed in any way. For example, that file may have been created but a crash occurred at that point in time (while it was being created), damaging the file. Now, my program which needs to...
3
2406
by: Jonck van der Kogel | last post by:
Hi everybody, I am having a hard time finding any info on this subject, so I was hoping maybe one of you could give me some pointers. I am writing an application in Java that uses Connector/J to interface with a MySQL database with InnoDB tables. When user #1 opens a certain recordset I am locking this recordset in share mode. Therefore if...
0
1245
by: Fast Eddie | last post by:
Hi, I'm writing a program (using mysql++) where I want users to be able to lock a row while they are editing it. My problem is I don't know how the 2nd user can detect the lock vs it looking like a failed query. I have innodb_lock_wait_timeout set to 1 second, which works fine, but mysql returns two errors when I try to update: ERROR...
1
1611
by: Danielb | last post by:
I need to create a read-only copy of Object X at run time, I know how to find the type of Object X (using GetType) but how do I go about creating a readonly copy of X? What I want to do is this: System.Type ValueType = Value.GetType(); create readonly object of type ValuteType and copy Value into it. Cheers,
3
5864
by: =B= | last post by:
Hi all, I was wondering if anyone has had any luck with trapping the <BODY> onUnload() event in ASP.NET? The thing is, I'm writing code for an Intranet site. The code makes a call to a third-party component (think of it as a lock) when the page loads. Now the OK and Cancel server buttons I can handle and use to release the lock as...
6
2122
by: Clark Sann | last post by:
Can someone help me understand what object should be used as the lock object? I've seen some programs that use Monitor.Enter(Me). Then, in those same programs, they sometimes use another object. Why? I would appreciate it if someone could help me understand the ramifications of picking an object in this command. Thank you so much for...
79
3729
by: VK | last post by:
I wandering about the common proctice of some UA's producers to spoof the UA string to pretend to be another browser (most often IE). Shouldn't it be considered as a trademark violation of the relevant name owner? If I make a whisky and call it "Jack Daniels", I most probably will have some serious legal problems. "Mozilla" partially...
4
2489
by: rodmc | last post by:
I have written an application which works perfectly when the machine is operating under normal conditions, however when the screen becomes locked it imediately starts to fill up several hundred MB's of memory. Is there a way to detect when the system is locked? Best, rod
12
1922
by: better_cs_now | last post by:
Hello all, I suspect that a threading issue is leading to an object being destructed in one thread context while one of its member functions is still running in another thread context. As a means of confirming this, I would like to have the object check if it is alive in the referenced member function and report to me if it is not. However,...
0
7664
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7885
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7638
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.