-
Some application just send data once then quickly close by design. and launched by cron etc. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
There are a couple ways you might achieve this, but all of them rely on either explicitly or implicitly waiting on the "shutdown complete" event before closing the object(s). The simplest way for a fire-and-forget style protocol would be to so something like the sample. You will notice the |
Beta Was this translation helpful? Give feedback.
-
Thanks! I did not notice the blocking call! |
Beta Was this translation helpful? Give feedback.
There are a couple ways you might achieve this, but all of them rely on either explicitly or implicitly waiting on the "shutdown complete" event before closing the object(s). The simplest way for a fire-and-forget style protocol would be to so something like the sample. You will notice the
RunClient
simply starts the connection async and then returns, eventually callingRegistrationClose
. The start will asynchronously kick off other work, like opening and sending stream data. The main thread that callsRegistrationClose
will block (wait) until the connection has been closed; so as long as the code cleans up asynchronously, correctly, eventually everything completes nicely and then returns…