Link to home
Start Free TrialLog in
Avatar of monkey3
monkey3

asked on

single or multiple threaded AND syncronisation

Ok, so I was under the impression that vb is single threaded correct?

well the scenario is thus...

We have a VB application, say "Reciever",
We have many instances of another VB application, say "Client"
We also have a VB COM+ "Event Server" application.

So the client calls a method on the Event Server which fires an event on the Reciever.
This event is handled and carries out some manipulation on the apps members.
In the mean time the app is carrying out its main line of execution.

While stepping through the main code, if an event is fired then the current line will jump to the event code.

So this would say to me that Reciever is multi threaded...

Anyway, when there are multiple Clients running, we get an automation error (-2147164155 OR 8004e005).
So we tried utilising Critical Sections to lock access to the array while in use.
When the main code is executing, we get a lock on the Critical Section and release it at the end of this iteration of the code.

When an event comes in, it attemps to get a lock and in theory has to wait until the lock is released by the main code.
In practice though the lock is granted which means it is implied that the event is in the same thread.

Chicken and egg has nothing on this!

how can we ensure cross-'Thread' sync'ing?
is vb truly single threaded?

m3
ASKER CERTIFIED SOLUTION
Avatar of Z_Beeblebrox
Z_Beeblebrox

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dang123
Dang123

monkey3,
    VB is normaly single threaded, but there are workarounds to do multithreading if you really really need to. Z_Beeblebrox's description does answer what you specificaly described in your question though.

http://www.freevbcode.com/ShowCode.Asp?ID=1287

Dang123