A semaphore by any other name.....
It's a shame that there isn't a more elegant approach. Actually there probably is but the documentation can be hard to decipher.
At least that confirms our suspicions.
BobJ
----- Original Message ----- From: "Martin Scholl" <[EMAIL PROTECTED]>
To: <u2-users@listserver.u2ug.org>
Sent: Monday, January 24, 2005 2:06 PM
Subject: RE: [U2] UniObjects and VB.Net



Okay, I got it to limp through the code.  Not beautiful, but I am not
getting mangled UniDynArrays anymore.

Here is what I do.
After I execute one line of UniDynArray gymnastics, I check if the object
has come back and is available before I execute the next line.

What was:
mitemClaim.SubValue(306, gintLineNumber, pintCount).StringValue =
pVarDTP_Array(1)
mitemClaim.SubValue(307, gintLineNumber, pintCount).StringValue =
pVarDTP_Array(2)
mitemClaim.SubValue(308, gintLineNumber, pintCount).StringValue =
pVarDTP_Array(3)

 Becomes:
     mitemClaim.SubValue(306, gintLineNumber, pintCount).StringValue =
pVarDTP_Array(1)
               Do While mitemClaim.StringValue = ""
                   System.Threading.Thread.Sleep(10)
               Loop
               mitemClaim.SubValue(307, gintLineNumber,
pintCount).StringValue = pVarDTP_Array(2)
               Do While mitemClaim.StringValue = ""
                   System.Threading.Thread.Sleep(10)
               Loop
               mitemClaim.SubValue(308, gintLineNumber,
pintCount).StringValue = pVarDTP_Array(3)
               Do While mitemClaim.StringValue = ""
                   System.Threading.Thread.Sleep(10)
               Loop

Ugly but it gets me through a product demo until I come up with something
better.
I have to see if there is a VB.Net way of checking if an Interop Call has
finished its thread and returned and released the argument.  I am just no
expert on this new .Net stuff

Another thing I discovered on my research is that there is a way to make
VS.Net single threaded by declaring at the beginning of a page:
System.Threading.Thread.CurrentThread.ApartmentState =
System.Threading.ApartmentState.STA
whereby STA stands for 'Single Threaded Apartment' as opposed to MTA
'Multi-threaded-Apartment'
This did not resolve my problem though.



Martin Scholl
President HIPAAsuite
18910 New Hampshire Ave
Brinklow, MD 20862
301-924-5537  Phone
301-570-0139  Fax
301-613-9572  Cell



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of BobJ
Sent: Monday, January 24, 2005 8:19 AM
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] UniObjects and VB.Net


That's definitely available with any of the .net languages and probably
could be gerry rigged simply by setting a semaphore. It also might mean
that the thing runs slow enough to be useless. Probably the better
alternative would be to manipulate the dynamic array with whichever U2 you
are using. Or it might work to make a flat file and use ADO and a stream
but you might run into the same thread problems. Or make a number of
smaller arrays so that the threads are less likely to collide. The problem
with that is "less likely" may be too likely. Possibly the best answer is
to ask the question on one of the MSDN news groups. They won't know what
you mean about dynamic array so you may have to change the wording a bit. A
dynamic array to a .NET developer, as you probably already know anyway, is
one that can be re-dimensioned at run time.
Let us know when and if you find an answer, please.
BobJ
----- Original Message -----
From: "Martin Scholl" <[EMAIL PROTECTED]>
To: <u2-users@listserver.u2ug.org>
Sent: Monday, January 24, 2005 7:22 AM
Subject: RE: [U2] UniObjects and VB.Net



Bob,
that is what what I observe.  Here is what I believe is happening:

VS.Not has a 'thunking' layer between its excution layer aka 'the
CLR(Common
Language Runtime)' aka 'virtual machine' aka 'Managed Code' and
UniObjects,
which is a dll that is compiled into machine code. For some reason this
'Interop Com Service' as Microsoft calls it, spawns off multiple threads
that manipulate the UniDynArray.  Those threads cross and mangle the
array.

I wonder if there is a way to make sure that one thread completes before
the
next one is started. A way to protect the UniArray from multiple access.

Martin Scholl
President HIPAAsuite
18910 New Hampshire Ave
Brinklow, MD 20862
301-924-5537  Phone
301-570-0139  Fax
301-613-9572  Cell



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of BobJ
Sent: Monday, January 24, 2005 5:47 AM
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] UniObjects and VB.Net


The words "thread safe" leap to mind. If there are multiple threads and
no
locks then mangling could be expected if a later launched thread assaults
part of the array before the earlier launched thread writes it back. Just
a
thought.
BobJ
----- Original Message -----
From: "Martin Scholl" <[EMAIL PROTECTED]>
To: <u2-users@listserver.u2ug.org>
Sent: Sunday, January 23, 2005 9:31 PM
Subject: [U2] UniObjects and VB.Net



I am using UniObjects ( the pre .Net version) in a VB.Net ASP.Net
application.

I am populating a UniDynArray with a file parser.  The Array is large,
more
then 300 attributes.
When I run this parser, my array is mangled.  Attribute contents are
mixed
with each other, attribute counts don't match with what I wrote in the
code.

When I run the code in the debugger, nice and slowly, I don't see a
problem,
only that sometimes it takes a second or to, for the UniDynArray to come
back from a call.  But when I run full speed, the mangling happens.

It looks like VB.NET starts several threads to deal with UniObjects, does
not wait until the thread is finished and then mangles the different
pieces.
Sometimes I get System.Runtime.InterOp.COMExceptions.


Has anybody had similar problems?  Found Work-arounds?

I can't move over to Uodotnet yet.  THere is too much code.  I though of
parsing my file into a Uodotnet.UniDynArray but then I saw that I can't
even
initialize a .Net UniDynArray with a session object.
Martin Scholl
President HIPAAsuite
18910 New Hampshire Ave
Brinklow, MD 20862
301-924-5537  Phone
301-570-0139  Fax
301-613-9572  Cell
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to