D dreamworld Active Member Licensed User Longtime User Jun 21, 2013 #1 In VB.net, I can use Synclock to prevent multi threads from executing the same codes simultaneously. I am wondering whether there is a similiar mechanism in B4A? I tried to find a answer by searching on this website, but I got nothing.
In VB.net, I can use Synclock to prevent multi threads from executing the same codes simultaneously. I am wondering whether there is a similiar mechanism in B4A? I tried to find a answer by searching on this website, but I got nothing.
agraham Expert Licensed User Longtime User Jun 21, 2013 #2 The Threading library dates from early in Basic4android history when there was no other asynchronous mechanism available. Nowadays good practice is for libraries to provide the asynchronism when necessary so I'm not sure when you would need a lock. However there is a Lock object in the library. Upvote 0
The Threading library dates from early in Basic4android history when there was no other asynchronous mechanism available. Nowadays good practice is for libraries to provide the asynchronism when necessary so I'm not sure when you would need a lock. However there is a Lock object in the library.
D dreamworld Active Member Licensed User Longtime User Jun 22, 2013 #3 dim A as new object Synclock A code line code line code line ... End Synclock Upvote 0
agraham Expert Licensed User Longtime User Jun 22, 2013 #4 I don't know what message you intend to convey by the post above but it comes over as terse and rude. Read the help for Lock. A Semaphore initialised unlocked can be used to control access to a resource. To acquire a resource the sequence for a thread is Wait() - use resource - UnLock(). Click to expand... Upvote 0
I don't know what message you intend to convey by the post above but it comes over as terse and rude. Read the help for Lock. A Semaphore initialised unlocked can be used to control access to a resource. To acquire a resource the sequence for a thread is Wait() - use resource - UnLock(). Click to expand...
D dreamworld Active Member Licensed User Longtime User Jun 22, 2013 #5 Excuse me. I did read the introduction of Lock, and then I tried to find some sample codes to help me understand how it works. Unfortunately, the sample I got after hard searching gave me an impression that Lock is for pausing a thread. Upvote 0
Excuse me. I did read the introduction of Lock, and then I tried to find some sample codes to help me understand how it works. Unfortunately, the sample I got after hard searching gave me an impression that Lock is for pausing a thread.
Erel B4X founder Staff member Licensed User Longtime User Jun 23, 2013 #6 Why do you need a Lock? Are you using the Threading library to create additional threads? Upvote 0
D dreamworld Active Member Licensed User Longtime User Jun 23, 2013 #7 Each socket needs a thread. And they access the same data. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Jun 23, 2013 #8 Are you using the Threading library to create additional threads? Click to expand... ??? If not then your code is running in the main thread. The libraries are responsible for running long tasks in the background (for example AsyncStreams). Upvote 0
Are you using the Threading library to create additional threads? Click to expand... ??? If not then your code is running in the main thread. The libraries are responsible for running long tasks in the background (for example AsyncStreams).