Re: Returning array of strings through callback from unmanaged to mana

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



The challenge is who's going to own the allocated memory? If it's the
method making the callback, then how does it ever get freed? If it's the
target of the callback, how does it know how much space to allocate?
Strictly speaking you could probably marshal them as an array of IntPtrs,
then do an IntPtr to String on each, but the potential for eitehr leaks or
invalid memory access is just too high. I'd consider rearchitecting.

-Chris



"Bruce Parker" <bparker@xxxxxxxxxxxxx> wrote in message
news:06270D80-50F0-413B-A977-B841F6D6FD63@xxxxxxxxxxxxxxxx
I have seen documentation that CF 2.0 supports arrays through interop. I
cannot find any solid examples of how to do this.

What I want to accomplish is to pass a callback function to unmanaged
code.
One of the parameters in the callback function is an array of strings.
The
unmanaged code will save the callback function and start a timer. When
the
timer fires, I need to be able to create an array of strings and pass that
back through the callback function to the managed code.

Does anyone have a code sample for this?


.



Relevant Pages

  • [RFC] typesafe callbacks?
    ... noone else voiced great enthusiasm about typesafe callbacks. ... the return type of the callback function ... diff -r 281ec5e7d696 include/linux/kthread.h ...
    (Linux-Kernel)
  • Re: SetTimer with no form?
    ... > VOID CALLBACK HeimdallTimerProc(HWND hwnd, UINT message, UINT_PTR ... From the MSDN docs for SetTimer: ... When you specify a TimerProc callback function, ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Hooking to windows callback function
    ... > I would like to hook this function (which is usually called WaveInProc). ... The callback function is passed as a parameter to waveInOpen and you need to ... control over the execution the second multimedia application you can create ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Ending a UI Thread?
    ... the reason for my thread is the following. ... I process messages from MIDI input ports. ... instead of using a callback function, ...
    (microsoft.public.vc.mfc)
  • Re: ::waveOutWrite() hangs
    ... essentially can I call::waveOutUnprepareHeader from OnWaveInData which is called by the callback proc. ... The docs state that one cannot call certain windows methods from the callback function, ... MMRESULT ret =::waveInUnprepareHeader waveFrame, sizeof ...
    (microsoft.public.win32.programmer.mmedia)