
Signature
Richard Beyea
SoftStuf Software, Inc
> Hi,
>
[quoted text clipped - 35 lines]
> is the comm area is pretty big (about 3000 bytes). And passing that around
> may not be the best solution.
I assume that the commarea is a byte array. Don't worry about "passing it
around" it's a reference type, and you are only passing a reference to it.
here's the right pattern:
public class UserInfo
{
string FirstName;
string LastName;
string Department;
}
public class CobolAdapter
{
public static string GetUserInfo(string UserName)
{
byte[] commArea = new byte[3000];
byte[] transactionArea = new byte[300];
byte[] requestArea = new byte[300];
//set appropriate data into buffers
CallCobolRoutine(commArea,transactionArea,requestArea);
bool success = false;
string errorMessage;
//marshal the return code into success
if (!success)
{
throw new RuntimeExeption("Cobol Routine Failed " + errorMessage);
}
UserInfo rv = new UserInfo();
//pull info from requestArea and marshal it into rv
return rv;
}
private static void CallCobolRoutine(byte[] CommArea, byte[]
TransactionArea, byte[] RequestArea)
{
//PInvoke COBOL .dll here
}
}
A possible optimization is to use a "Object Pool Pattern" to recycle the
buffers.
David
rbeyea - 26 Aug 2005 02:13 GMT
David,
Thanks! It is about the same I was was thinking. I think I get too hung up
on what the patterns should be.
I will look into then "Object pool pattern".
Thanks again!
rich
Hello David Browne" davidbaxterbrowne no potted,
>> Hi,
>>
[quoted text clipped - 87 lines]
>
> David