From 611e48abbbcaea7e59352c277db0ca2c24369eb8 Mon Sep 17 00:00:00 2001 From: Christoph Cullmann Date: Tue, 5 Apr 2022 22:46:42 +0200 Subject: Provide API for blocking sendMessage (#154) --- singleapplication.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'singleapplication.h') diff --git a/singleapplication.h b/singleapplication.h index 91cabf9..5565bb8 100644 --- a/singleapplication.h +++ b/singleapplication.h @@ -124,14 +124,24 @@ public: */ QString currentUser() const; + /** + * @brief Mode of operation of sendMessage. + * @enum + */ + enum SendMode { + NonBlocking, /** Do not wait for the primary instance termination and return immediately */ + BlockUntilPrimaryExit, /** Wait until the primary instance is terminated */ + }; + /** * @brief Sends a message to the primary instance. Returns true on success. * @param {int} timeout - Timeout for connecting + * @param {SendMode} sendMode - Mode of operation. * @returns {bool} * @note sendMessage() will return false if invoked from the primary * instance. */ - bool sendMessage( const QByteArray &message, int timeout = 100 ); + bool sendMessage( const QByteArray &message, int timeout = 100, SendMode sendMode = NonBlocking ); /** * @brief Get the set user data. -- cgit v1.2.1