Derived From:
Mix-in Classes:
Declared In:app/MessageRunner.h
Allocation:Constructor only
Class Overview

Constructor and Destructor


BMessageRunner(BMessenger target,
               const BMessagemessage,
               bigtime_t interval,
               int32 count = -1);
BMessageRunner(BMessenger target,
               const BMessagemessage,
               bigtime_t interval,
               int32 count,
               BMessenger replyTo);

Tells the roster to send the specified message to the target BMessenger every interval microseconds. The message will be sent count times (if count is -1, the message will be sent forever, or until the BMessageRunner is reconfigured or deleted).

The second form of the constructor lets the application specify, in replyTo, the BMessenger to which replies to the message should be sent.

The BMessageRunner can be reconfigured (to change the interval or count) by calling SetInterval() and SetCount().

After constructing a BMessageRunner, you should call InitCheck() to ensure that the object was created properly.


virtual ~BMessageRunner();

Asks the roster to stop sending the message.

Member Functions


status_t GetInfo(bigtime_t* interval,
                 int32* count) const;

GetInfo() returns in interval the time in microseconds that will pass between messages being sent, and in count the number of times the message will be sent.

Return CodeDescription


Information returned successfully.


The roster returned invalid information about the BMessenger.


The roster returned invalid information about the BMessenger.

Other errors.

In general, getting an error back from this function is a bad thing.


status_t InitCheck() const;

InitCheck() returns a result code indicating B_OK if the BMessageRunner constructor executed sucessfully, or some other value if an error occurred setting up the object. You should call this immediately after creating a BMessageRunner, and shouldn't use the object if this function returns anything but B_OK.


status_t SetCount(int32 count);

SetCount() sets the number of times the BMessageRunner will send the message. If you want the message to be sent forever (until the object is deleted or SetCount() is called again), specify -1.


status_t SetInterval(bigtime_t interval);

SetInterval() sets the number of microseconds that will pass between messages being sent.

Creative Commons License
Legal Notice
This work is licensed under a Creative Commons Attribution-Non commercial-No Derivative Works 3.0 License.