473,499 Members | 1,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Does MethodImpl Synchronized atribute is like lock(this) ?

Hi,

Does MethodImpl Synchronized attribute is like lock(this) ?
i mean that a call to Monitor.PulseAll(this) from a Synchronized method will
trigger other thread that call to Monitor.Wait(this) ?

Thanks.

Nov 30 '05 #1
2 3541
yaron,

Yes, MethodImpl Synchronized is implemented exactly like that it uses
lock(this) for the entire method. It can be easily tested. However I don't
see anywhere in the docs this documented so I don't know if it is a good
idea to build your code based on this presumption.

On the other hand the implementation is still the same in .NET 2.0.

Why you want to use MethodImp attribute? Why you don't use lock statements?
lock(this) is not always a good idea.

Take a look at this article it has some guidlines of how to use different
sync techniques.
http://msdn.microsoft.com/library/de...netchapt05.asp
HTH

Stoitcho Goutsev (100) [C# MVP]
"yaron" <ya***@discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
Hi,

Does MethodImpl Synchronized attribute is like lock(this) ?
i mean that a call to Monitor.PulseAll(this) from a Synchronized method
will
trigger other thread that call to Monitor.Wait(this) ?

Thanks.

Nov 30 '05 #2
yaron wrote:
Hi,

Does MethodImpl Synchronized attribute is like lock(this) ?
i mean that a call to Monitor.PulseAll(this) from a Synchronized method will
trigger other thread that call to Monitor.Wait(this) ?

Thanks.


Should be easy to test.

--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:la***@vkarlsen.no
PGP KeyID: 0x2A42A1C2
Nov 30 '05 #3

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

Similar topics

3
1897
by: Frazer | last post by:
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.? can anyone illustrate with an example.
6
437
by: n_o_s_p_a__m | last post by:
I have seen some debate but am not clear on what the problematic implications of the expression lock(this) are. Microsoft seems to advocate it, but others seem to be against it. Pros and cons? ...
4
1538
by: Max Adams | last post by:
All, I have a multithreaded app (using threadpool). I was under the illusion that where I used lock( this ) around a segment of code that only one thread would be allowed access to that segment...
0
7007
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
7174
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,...
1
6894
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...
1
4919
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
4600
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...
0
3099
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...
0
3091
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
665
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.