473,386 Members | 1,706 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,386 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 5434

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?
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...

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.