473,471 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Critical Sections of code

I have a multi-threaded VB.NET application and I need to be able to access a
shared set of variables from multiple threads. In CE.NET there are objects
called critical section objects that a thread can acquire on entry to a
section manipulating such variables and release when done. Any other thread
trying to acquire the same object will suspend until the object is released.

Is there such a mechanism in VB.NET please?

Thanks,
Sid.

--
Sid Price's Software Tools.
http://www.Softtools.com
Nov 21 '05 #1
5 4682
Hi,

http://msdn.microsoft.com/library/de...tmsynclock.asp

Ken
-------------------
"Sid Price" <no****@nowhere.com> wrote in message
news:u5**************@tk2msftngp13.phx.gbl...
I have a multi-threaded VB.NET application and I need to be able to access
a shared set of variables from multiple threads. In CE.NET there are
objects called critical section objects that a thread can acquire on entry
to a section manipulating such variables and release when done. Any other
thread trying to acquire the same object will suspend until the object is
released.

Is there such a mechanism in VB.NET please?

Thanks,
Sid.

--
Sid Price's Software Tools.
http://www.Softtools.com

Nov 21 '05 #2
Its a bit difficult to describe it all here, but yes it does. Look up the
"Synclock" keyword on the net.

"Sid Price" <no****@nowhere.com> wrote in message
news:u5**************@tk2msftngp13.phx.gbl...
I have a multi-threaded VB.NET application and I need to be able to access
a shared set of variables from multiple threads. In CE.NET there are
objects called critical section objects that a thread can acquire on entry
to a section manipulating such variables and release when done. Any other
thread trying to acquire the same object will suspend until the object is
released.

Is there such a mechanism in VB.NET please?

Thanks,
Sid.

--
Sid Price's Software Tools.
http://www.Softtools.com

Nov 21 '05 #3
In addition to Ken's information you may find the Mutex useful.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Sid Price" <no****@nowhere.com> wrote in message
news:u5**************@tk2msftngp13.phx.gbl...
I have a multi-threaded VB.NET application and I need to be able to access
a shared set of variables from multiple threads. In CE.NET there are
objects called critical section objects that a thread can acquire on entry
to a section manipulating such variables and release when done. Any other
thread trying to acquire the same object will suspend until the object is
released.

Is there such a mechanism in VB.NET please?

Thanks,
Sid.

--
Sid Price's Software Tools.
http://www.Softtools.com

Nov 21 '05 #4
"Sid Price" <no****@nowhere.com> schrieb:
I have a multi-threaded VB.NET application and I need to be able to access
a shared set of variables from multiple threads. In CE.NET there are
objects called critical section objects that a thread can acquire on entry
to a section manipulating such variables and release when done. Any other
thread trying to acquire the same object will suspend until the object is
released.

Is there such a mechanism in VB.NET please?


Check out the 'SyncLock' statement and the .NET Framework's 'Monitor' class.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5
Thanks to all for the great references and pointers.

Sid.

--
Sid Price's Software Tools.
http://www.Softtools.com

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
"Sid Price" <no****@nowhere.com> schrieb:
I have a multi-threaded VB.NET application and I need to be able to access
a shared set of variables from multiple threads. In CE.NET there are
objects called critical section objects that a thread can acquire on entry
to a section manipulating such variables and release when done. Any other
thread trying to acquire the same object will suspend until the object is
released.

Is there such a mechanism in VB.NET please?


Check out the 'SyncLock' statement and the .NET Framework's 'Monitor'
class.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #6

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

Similar topics

77
by: Charles Law | last post by:
Hi guys I have a time critical process, running on a worker thread. By "time critical", I mean that certain parts of the process must be completed in a specific time frame. The time when the...
2
by: Xarky | last post by:
Hi, I am trying to learn Critical Sections. I have written a small program. Source code problem below. What the program is doing is disabling the CRTL-C signal in the critical section. My...
7
by: Piotrek Stachowicz | last post by:
Hi, I need to create the situation in my system, where no more critical sections can be initialized (win2000Server). I thought about creating a simple c# application and using the Monitor class....
6
by: MPH Computers | last post by:
Hi I am looking for some help on Threading and Critical Sections I have a main thread that controls an event the event handler creates a new thread for carrying out the work because the...
13
by: Hendrik van Rooyen | last post by:
Hi, I would like to do the following as one atomic operation: 1) Append an item to a list 2) Set a Boolean indicator It would be almost like getting and holding the GIL, to prevent a...
5
by: =?Utf-8?B?VmFubmk=?= | last post by:
Hi, I have a component where I need to have thread-safe access to a list. Operations on the list are done in critical sections (lock (lockObject) { ... } ) in the usual way, to make sure that no...
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
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
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,...
1
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
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.