[solved] CreateThread/GetCallbackPtr issues - 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: [solved] CreateThread/GetCallbackPtr issues (/showthread.php?tid=87948) [solved] CreateThread/GetCallbackPtr issues by Danny22 on 12-24-2008 at 07:18 PM
Hello, code: Callback function: code: Any ideas? RE: CreateThread issues by matty on 12-24-2008 at 07:29 PM
The GetCallbackPtr has to actually be a callback not one just defined by the user. RE: CreateThread issues by Danny22 on 12-24-2008 at 07:32 PM I see. Thank you very much for your quick reply. RE: CreateThread issues by Eljay on 12-24-2008 at 07:41 PM
quote: Not quite sure what you are on about here matty GetCallbackPtr was meant for exactly that purpose really. However, the reason the OP's code doesn't work is that CreateThread needs an asynchronous callback to work, and unfortunately, Plus! only supports synchronous callbacks due to technical limitations of the scripting engine. RE: [solved] CreateThread issues by matty on 12-24-2008 at 07:46 PM
quote: We will discuss this later on MSN Looks like I am talking out of my ass again... I could have swore it was defined internally in Messenger Plus!... if not what am I thinking of... RE: [solved] CreateThread issues by Danny22 on 12-24-2008 at 07:48 PM
Thanks, Eljay and matty. RE: [solved] CreateThread issues by Eljay on 12-24-2008 at 08:12 PM
The way I see it, Plus! has one internal (native) function that is used as a callback. When you call GetCallbackPtr, Plus! stores the name of the function and the script engine object for the script that called it. This is why the callback must be used immediately and synchronously, because other scripts calling GetCallbackPtr would screw everything up. quote: Most likely yes, maybe if you explained what you were trying to accomplish we can help out. RE: RE: [solved] CreateThread issues by Danny22 on 12-24-2008 at 08:29 PM
quote: Thanks. I appreciate it. I installed VC++ (Express 2008) and I'll give it a try. My code has a long loop and calls to the Sleep WinAPI to control the speed. The sleep/delay should be pretty quick (10 ms), so I cannot use Plus! timers as I see it. However, this would stall everything else in WLM/Plus!, so I need it to run in a different thread. It is supposed to do smooth animation/movement on a custom window. I am not sure how you can help but I'll let you know how it goes. RE: [solved] CreateThread issues by Mnjul on 12-24-2008 at 08:39 PM
matty and Eljay: you both are both wrong and right RE: [solved] CreateThread issues by Danny22 on 12-25-2008 at 12:19 AM
I gave it a shot and made a simple example DLL. RE: [solved] CreateThread issues by Matti on 12-25-2008 at 09:32 AM
quote:So, if I understand this correctly, Plus! declares a number of static functions which all accept a certain number of numeric arguments. Then, based on the function passed through GetCallbackPtr, Plus! determines the amount of arguments the passed JScript function accepts and returns the pointer of the static function with the same amount of arguments... This means, for two scripts attempting to use a function pointer for an asynchronous call, two scripts requesting a function pointer with the same amount of arguments are much more likely to interrupt each other than two scripts requesting a function pointer with a different amount of arguments. Am I right about this? Is this what we should know about using GetCallbackPtr? Or did I go wrong somewhere? RE: [solved] CreateThread/GetCallbackPtr issues by Pinecone on 12-26-2008 at 10:15 AM
I could be wrong, but my understanding about knowing if a function was called with the right number of arguments or not, is checking for a stack imbalance after the call, hence why the plus documentation says to only call functions with stdcall convention. |