Shoutbox

Interop.GetCallbackPtr - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Interop.GetCallbackPtr (/showthread.php?tid=86863)

Interop.GetCallbackPtr by paulspiteri on 10-25-2008 at 01:34 PM

Hi
I know there's a warning in GetCallbackPtr to not use it asyncronously, but how dangerous is that, really? I haven't done any experiments yet but I'm wondering how often the pointer really does change.
I've got a script that does some polling to a .NET DLL via COM to check if there's any new data, but i'd love to change that so the .NET code makes a callback to the script using this pointer.
I did try it actually, but couldn't convert the pointer into a delegate (anyone else tried that?). If i'm going to try again, i'm thinking of making a managed C++ assembly to make the callback call.

Anyone else out there have any thoughts?
Thanks
Paul


RE: Interop.GetCallbackPtr by ShawnZ on 10-25-2008 at 01:36 PM

what are you doing in the  .NET dll exactly? you might be able to accomplish this just using scripting...


RE: Interop.GetCallbackPtr by felipEx on 10-25-2008 at 08:57 PM

quote:
Originally posted by paulspiteri
Hi
I know there's a warning in GetCallbackPtr to not use it asyncronously, but how dangerous is that, really?l
quote:
Originally posted by Patchou
The documentation specifically mentions that this function can only be used for synchronous calls. If you make a script that defys this rule, it may work at first but the combination of several scripts will certainely cause unexpected results / crashes.
quote:
Originally posted by Patchou
the problem is a technical limitation: for callbacks I dont have much other choice than using static functions in my code so I cant have two scripts using a callback at the same time, which is why they have to be synchronous.
...
Thus right now, calling GetCallbackPtr() many times, from different scripts, will always return the same pointer for a function with a given number of arguments.
read Cookie's reply
RE: Interop.GetCallbackPtr by paulspiteri on 10-25-2008 at 11:43 PM

Okay I got it working

But I get a warning..

Bad calling convention detected for .......... The function must be declared with __stdcall and called with the appropriate number of parameter.


My function is defined as:

extern "C" _declspec(dllexport)int Test(int* test);

if i change it to
extern "C" _declspec(dllexport)int __stdcall Test(int* test);

then it says the function could not be found!

How do I fix that?
thanks


RE: Interop.GetCallbackPtr by felipEx on 10-26-2008 at 12:07 AM

RE: Trouble creating a DLL that works in Plus ;)


RE: Interop.GetCallbackPtr by paulspiteri on 10-26-2008 at 02:14 PM

Hi
I'd already tried that - when i add __stdcall, it doesn't find the function at all!
Any ideas?