Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Eric_B

asynchronous function

This topic is 5745 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
I don't want to create a new thread, I just want a function that returns right after passing the parameters to another fuction like postmessage function for windows.

I'm using a timer control for this, but I want to make my own function that has the same effect.

I could make a thread and use postthreadmessage function but is there any other less complex way?

Any ideas ?

[edited by - Eric_B on January 24, 2003 5:28:41 AM]

Share this post


Link to post
Share on other sites
i/o completion ports
asynchronous procedure calls (APC)
thread pools

you understand that one thread cannot execute two pieces of code simultaneously, right? APCs, see for instance QueueUserAPC, will only be executed when your thread is in alertable wait state, and thus is not executing any code. APCs are closest to PostMessage/GetMessage combo that you''re describing. thread pools (see, for instance, QueueUserWorkItem) are also similar in that you use them in much the same way, but the actual procedure is run on another thread and thus can run at the same time as the thread that called QueueUserWorkItem.

i/o completion ports can be used for non-i/o purposes, but you need to manage the threads yourself. iocp requires alertable waiting.

there are really two ways to get things done asynchronously:
- start a new thread for background processing - CreateThread, thread pooling, and iocp fall here
- execute the code on the same thread that called it, but delay execution until the thread is waiting - APCs and windows messages fall here.

Share this post


Link to post
Share on other sites
niyaw, thanks for the reply.

I have an outprocess com dll and implemented an event, but the main problem is the client waits for the funtion (in my out-of-process com dll) to finish. The function in com dll takes a lot of time and I don't want my client to wait for the return. I've tried function pointers and everything I could think, but the client still waits for the return.

what are asynchronous procedure calls (APC), how do you make these calls?

thanks

[edited by - Eric_B on January 24, 2003 7:24:09 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by Eric_B
I have an outprocess com dll and implemented an event, but the main problem is the client waits for the funtion (in my out-of-process com dll) to finish. The function in com dll takes a lot of time and I don''t want my client to wait for the return. I''ve tried function pointers and everything I could think, but the client still waits for the return.


have you considered asynchronous RPC (remote procedure call)? it may not be as easy to use as com objects (and i''ve never heard of our-of-process com *dll*s), but they have pretty cool async call support.
quote:

what are asynchronous procedure calls (APC), how do you make these calls?


use QueueUserAPC function. APC is a piece of code that''s executing while a thread is performing an alertable wait on something, be that a kernel object, a windows message, or an i/o completion event.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!