473,378 Members | 1,500 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,378 software developers and data experts.

who has that object locked?

cs
I have an app that freezes on trying to lock an object, probably cause
someone else has the lock and they aint giving it back. How can I find out
who has that lock?
Nov 16 '05 #1
3 1509
cs,

You can't really, as that information is not exposed. You need to track
down the deadlock and remove it. The information on what thread holds the
lock is kept internally (by the Monitor class, most likely).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"cs" <[rem]casolorz[rem]@hot[rem]mail.com> wrote in message
news:Ow**************@TK2MSFTNGP12.phx.gbl...
I have an app that freezes on trying to lock an object, probably cause
someone else has the lock and they aint giving it back. How can I find out
who has that lock?

Nov 16 '05 #2
"cs" <[rem]casolorz[rem]@hot[rem]mail.com> wrote in message
news:Ow**************@TK2MSFTNGP12.phx.gbl...
I have an app that freezes on trying to lock an object, probably cause
someone else has the lock and they aint giving it back. How can I find out
who has that lock?


I can't help you solve that, but there is a lesson here: do not lock
publicly visible objects. code like

lock(this) {
...
}

is inherently dangerous, since any code that can see "this" can also lock
it, potentially causing deadlocks, hangs, race conditions, etc. A much
better choice is:

private Object lock = new Object;

lock(this.lock) ...

Now you know that any code which locks the object is in the same class.
Even if you provide a public accessor for the lock (usually unnecessary and
generally a bad idea):

public Object Lock {
get { return lock; }
}

you can now add tracing here to track down the culprit.

In other words, monitors are not an exception to the rule that public
mutable fields are a bad idea.

Nov 16 '05 #3
If you are really, really, stuck, you can use windbg with some other
tools to troubleshoot deadlocks.

See
http://msdn.microsoft.com/library/de...html/DBGrm.asp

--
Scott
http://www.OdeToCode.com
On Mon, 21 Jun 2004 14:51:55 -0500, "cs"
<[rem]casolorz[rem]@hot[rem]mail.com> wrote:
I have an app that freezes on trying to lock an object, probably cause
someone else has the lock and they aint giving it back. How can I find out
who has that lock?


Nov 16 '05 #4

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

Similar topics

0
by: Sanya Shaik | last post by:
--0-1681303956-1057931436=:59957 Content-Type: text/plain; charset=us-ascii Hi, I am a new admin and I was recently ran into a problem - When I execute the show processlist command I see...
0
by: Tech | last post by:
In Visual Basic 6.0, the Locked property of a ComboBox control determined whether the text-box portion of the control could be edited. In Visual Basic ..NET, the Locked property prevents a control...
1
by: Mel Apiso | last post by:
Hi, I want to know if I can detect exactly what row table is locked. My application is locked and I get valuable information (table, application, lock mode...) with "get snapshot for locks..."...
0
by: Ken Linder (KC7RAD) | last post by:
All, Is this a bug or a feature? If a user is locked, GetPassword() throws an exception. Here's my web.config entry for the provider... <membership> <providers> <remove...
7
by: Andrea Moro | last post by:
I'm writing my first windows control library. A simple textbox with some numeric facilities. Well, there is a strange thing that happen. I want to add a locked property. As many other property,...
4
by: Qwert | last post by:
Hello, I have a listview with an image list. After dispoing the images and the image list, the bitmap files remain locked: REM Create. objImage = Image.FromFile(strBmp) If...
4
by: Giggle Girl | last post by:
I have inherited a stylesheet at work, with the designer no longer working here. In an external stylesheet it says: thead th, thead th.locked { position:relative; }
4
by: kafi | last post by:
Hi All; I am trying to find a way to make my locked control more visible on a web form. When I lock a control and display it on a web form (ASP.NET) the control is barely visible and it is hard...
7
by: RichG | last post by:
I want to lock all controls except the buttons on a form. I sometimes need the form to call lockForms(Me). public sub lockControls(frm as form) for each ctrl as control in frm if...
8
by: kevin.vaughan | last post by:
Good Afternoon Everyone, Could someone please explain why I can't set the Subform control Visible attribute to False as below? The statement for the locked attributes work but not for the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.