How to programmatically toggle ToggleButtons?

It occurs to me that perhaps the problem is that the click is triggered asynchronously. Maybe this is the Right Thing?:

void setMute(bool b) {
if (b != getMute()) {
muteToggleButton.get()->setToggleState(b,sendNotificationSync);
}
}

It seems to be working…