Skip to main content
Inspiring
June 9, 2014
Answered

How to delete a idle hook?

  • June 9, 2014
  • 1 reply
  • 1382 views

Hey guys!

I'm using AEGP_RegisterIdleHook() to schedule a task for after effects when it has free time. But Idle hook will run whenever after effects is free. What I want to do is just run the hook function one time, then delete the idle hook, can I do that? How?

Thanks

This topic has been closed for replies.
Correct answer shachar carmi

Well, I tested it. I removed the socket server and call the AEGP_RegisterIdleHook fucntion from the entry point function, this time after effects doesn't freeze anymore. Does that mean I can't call AEGP_RegisterIdleHook function from a external tread too?


you can call any AE function from an external thread!

what you should do is:

1. in your entry point function register the idle hook, and launch the

external thread.

2. have your external thread stroke it's gotten data in some global scope

structure.

3. when AE calls your idle hook function, check if that global scope

structure was filled and ready to be used. if so, execute you processing

code from within the idle hook. if not, check again next time around.

4. done? set your "skip idle hook" flag to true so you don't process again,

and kill the external thread.

5. you're done. go to lunch.

alternatively, you can make a sychronized call to your server from within

the idle hook call, and save yourself the external thread stuff.

i repeat the idea behind all of this:

you may only use AE suites when AE is ready for it.

when is AE ready for it?

only when AE calls you. (i.e. the entry point function or idle hook

function)

so you have to register the idle hook and perform your operations that

interface with AE at such a time.

On Mon, Jun 9, 2014 at 1:00 PM, Zhiqiang_Li <forums_noreply@adobe.com>

1 reply

Community Expert
June 9, 2014

err... i don't know if there's an "unregister" function where you can sign

off of the request to receive idle hook calls.

you can just set a flag in your plug-in which will bypass the idle hook

code after the first run.

On Mon, Jun 9, 2014 at 11:46 AM, Zhiqiang_Li <forums_noreply@adobe.com>

Inspiring
June 9, 2014

Here's what I'm doing right now.

BOOL SWITCH = TRUE;

static

A_Err

IdleHook(

AEGP_GlobalRefcon plugin_refconP,

AEGP_IdleRefcon refconP,

A_long *max_sleepPL)

{

  *max_sleepPL = 500;

  A_Err err = A_Err_NONE;

  if (SWITCH)

  {

  // do something...

  SWITCH = FALSE;

  }

  return err;

}

But I'm doing it wrong, because the IdleHook function still runs whenever after effects is free. And that will cause after effects froze.

Can you give me some suggestion shachar carmi

Community Expert
June 9, 2014

i don't see how this code can make AE freeze. seriously. you're doing it

right.