Jump to content

Inserting a non-blocking wait into a callback VI


Recommended Posts

I have a large application with multiple parallel loops\threads\processes\etc. One of these processes is and embedded instance of MediaPlayer. I wish to instigate a stop signal some time after MediaPlayer finishes playing whatever it is playing. The obvious avenue to accomplish this is to use a "Register Event Callback" node to register a callback VI to execute when MediaPlayer produces a "wmppsMediaEnded" activeX event.

At this point in time, my stop signal can be instigated by generating a user event in the main VI (cleverly named "Stop") which begins stopping all the parallel processes. (Note: I'm not splitting the user event registration accross several event nodes or anything like that--the Stop user event just calls a bit of code that changes several "state" LV2 globals which put the parallel loops into an "idle" state). Therefore, I added the User Event refnum as a User Parameter when registering the callback VI. In the callback VI, I simply generate the Stop event, and everything stops. All this works fine.

The problem is that I wish to create a delayed stop, say 5 seconds after the "wmppsMediaEnded" event occurs. When I try to add a wait in the callback VI itself, it freezes everything in the main VI, including all the parallel loops. It seems like the callback VI stops all other LV processes and the main VI must wait until the callback VI finishes executing.

Is there any way to create a non-blocking callback VI?

Link to comment

I don't know much about the callbacks, but it seems plausible to me that when you mess with the operating system, it messes with you. You might try having your stop VI post a new User Event that does the 5 second wait. That way the callback can go ahead and return, but you can still have the delay in your LV app before you do whatever it was you wanted to do next. Of course, that won't help if what you want to do after those 5 seconds is something to Medial Player itself.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.