Is there any way to protect a method in a threading evnironment, so that only one thread gets to call the function at a time (like the synchronized attribute in java)?
Hello Raste,
I have never tried to create a multithreaded application in VB.net so what you will read here is out of the MSDN.
Synchronization [Visual Basic]
"Synchronization is a logical thread of execution, sometimes called an activity. COM+ provides synchronization that flows from object to object and prohibits more than one caller from entering the component at any given time. Synchronization determines when threads can dispatch calls to an object.
To use automatic synchronization, apply the SynchronizationAttribute attribute to a class that derives from System.EnterpriseServices.ServicedComponent.
If the caller is configured to support or require automatic transactions, the value of the SynchronizationOption enumeration is automatically set to Required. If the caller is configured to require a new transaction, the enumeration is set to RequiresNew.
The following example shows how to enable synchronization on instances of the TestSync class:
Code:
[Visual Basic]
<Synchronization()> _
Public Class TestSync
Inherits ServicedComponent
"
I hope that this helps.
MSDN link:ms-help://MS.VSCC/MS.MSDNQTR.2002APR.1033/cpguide/html/cpconsynchronizationactivity.htm "The Camel will walk the desert of programming once again ..."
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.