473,398 Members | 2,188 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,398 software developers and data experts.

Difference between synclock and mutex

Hi. I'm new to multithreading applications in .NET. What exactly is the difference between using synclock on a variable or using mutex.waitone/mutex.releasemutex
There is too much stuff out there on multithreading and I can't find a simple answer
Also, is this a "normal" way of writing to files in multithreading applications

Dim objReader As StreamWrite
SyncLock (objReader
objReader = New StreamWriter(System.AppDomain.CurrentDomain.BaseDi rectory & ERR_FILE_NAME
objReader.Write(some message
objReader.Close(
End SyncLoc

Thank
JS
Jul 21 '05 #1
1 5438

SyncLock is just a language shortcut for using the Monitor class and
its Enter and Exit methods.

The main difference between Monitor and Mutex is that Mutex wraps the
native Win32 mutex, so it can be used across processes and to
synchronize managed and native code. Monitor is only for managed code
and for use within the same appdomain.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #2

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

Similar topics

4
by: Ram | last post by:
Hey, I have about 5 Shared variables, that I want to be locked for access when they are written to. I'v read in the MSDN about the SyncLock statement, and I'm prety sure that's what I'm looking...
12
by: Keith Langer | last post by:
I have some questions about whether synclock is necessary in a few different scenarios: 1) I have a Queue class which is shared between two threads. Thread 1 pushes objects onto the queue and...
4
by: Charles Law | last post by:
I've been using monitors a bit lately (some of you may have heard ;-) ) and then up pop Manual and AutoResetEvents , and they look for all the world like the same thing. Are they...
4
by: Jeff Stewart | last post by:
Specifically, I don't understand the parameter that Synclock accepts. How is a reference type a lockable entity? What -is- a reference type? Is it a number? Is it a value at a specific memory...
7
by: Chris Dunaway | last post by:
Suppose I have several threads that need to access the same object. ThreadA successfully acquires the lock using SyncLock. ThreadB attempts to acquire the lock and blocks and then ThreadC attempts...
1
by: JennaS | last post by:
Hi. I'm new to multithreading applications in .NET. What exactly is the difference between using synclock on a variable or using mutex.waitone/mutex.releasemutex There is too much stuff out there on...
2
by: Spam Catcher | last post by:
Hi all, I'm hosting a remoting service in IIS. I have a function which I only want one concurrent access at a time. Will this prevent multiple users from accessing the function at a paritcular...
2
by: HONOREDANCESTOR | last post by:
I have a buffer that needs to be locked sometimes, because 2 processes update it. So I made the buffer into a class and whenever there is code that affects it, I sandwich the code between ...
2
by: cj | last post by:
I take it a mutex is like a synclock but visible outside the program?
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.