Hi,

I'm using a serial port (module (B)) which has a default vDataReceivedEventHandler. This handler is connected through a 'callback' delegate to the calling module (A) which module (A) instanciates the serial port module (B). If I create a byte array in module (A) then the delegate passing data from module (B) to module (A) has no access to this module (A) byte array.
How does my delegate get access to a module (A) variable?

thanks,

Henk

Can you post your code to your setup?

You simply need to pass the array in as part of the delegate parameter, if you need something more complicated you need either Shared Memory or a Proxy Class (same thing just better managed :) )

Hi,

module (A) instanciates comport module (B). Module (B) calls (through a delegate) a funtion in module (A) each time the comport module (B) receives a character. I simply want module (A) to put these received characters in an array inside module (A). I declare a byte array in (A). When a character is received by comport module (B) then (B) calls that delegated function in (A) but from within that delegated function in (A) there is no access to the declared byte array in (A). It says that the character array pointer is null.

hth

Henk

Hi,

My problem is solved. I mixed up C, C++, C# and Delphi. I only declared the module (A) byte array without creating a variable of it.... (ashame, ;-)). I thought that when some module accesses an anchestor module then there was some special mechanism needed to communicatie.

It all works fine now.

Thank for listening anyway.

Henk

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.