Method ToggleEnabledAsync
- Namespace
- OBSStudioClient.Model
- Assembly
- OBSClient.dll
ToggleEnabledAsync(CancellationToken)
Shows the scene item when it is hidden, and hides it when it is shown, and returns when the model shows it.
public Task<bool> ToggleEnabledAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that ends the wait. A change that was not sent yet is not sent.
Returns
Remarks
OBS Studio has no request that toggles a scene item. When its turn has come, after every change that you asked for before it has been answered, the change asks OBS Studio whether the item is shown, and sets the opposite. So two calls make two toggles, in the order in which you asked for them, and a change that you asked for between them is not overtaken: what a toggle turns over is what OBS Studio holds at its turn, not what the model showed when you called (the model can be a few milliseconds behind OBS Studio, and does not know yet what a change that was just answered did).
The question changes nothing: when OBS Studio does not answer it in time, or the connection ends meanwhile, nothing was changed. See SetEnabledAsync(bool, CancellationToken) for the order of changes and the wait.
Exceptions
- ObsRemovedException
The scene item, or its scene, was removed.
- ObsNotConnectedException
There is no connection to OBS Studio. Nothing was changed.
- ObsNotReadyException
OBS Studio is changing its scene collection, or did so after the call, or did not say in time whether the item is shown. Nothing was changed.
- ObsUnknownOutcomeException
OBS Studio did not answer in time, or the connection ended: it is not known whether it made the change.
- ObsNotConfirmedException
OBS Studio made the change, and the model does not show it: the events did not show it in time, and the model could not be read again in time. Do not send the change again.
- ObsResponseException
OBS Studio refused the change.