[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

Assigning address of a variable in VC#.NET to a variable in VC++.N

Castratroi

5/17/2007 12:57:00 AM

Hi,

I have a VC#.NET DLL (Visual Studio 2005), which runs a simple UDP server.
It receives position updates from the client, and sends images from a folder
in real-time accordingly. I have added this DLL to a virtual 3D enviornment,
written in VC++.NET (Visual Studio 2005).

This images being sent to the client are created,rendered and stored by the
VC++ application. Hence, when the DLL receives the updates from the client,
it has to inform the VC++ application to render and save the required image
at the required position.

Initially I had a public variable in the DLL, which was set to true when an
update was received. I was creating an instance of the DLL class in VC++
application and checking the DLL variable in a while(true) loop (within a
thread). Even though this operation was taking place in a thread, it really
slowed the server down (I have no idea why this was happening).

So, I decided to remove the thread. I wrote the following function in VC#,
which returns the address of the variable.

public unsafe int* ReturnAddressPositionUpdate()
{
fixed(int* ReturnValue = &ReceivedPositionUpdate)
{
return ReturnValue;
}

}

I am calling this function from the VC++ code as:

NewPosition =c->ReturnAddressPositionUpdate();

(where c is the instance of the VC# class, and NewPosition is the local VC++
variable, both are declared as int)

When I debug the code, I get the same address for both the variables( that
is, the one in VC# and the one in VC++), yet when the variable is updated by
VC# client, the if(*NewPosition != 0) statement in VC++ does not detect the
update (The if () statement is being called recursively, so it keeps on
checking, yet it never detects the updated variable value, yet during debug
the value does get updated in VC#).

Kindly help me out here.

Thanks