Method SetEnabledAsync
- Namespace
- OBSStudioClient.Model
- Assembly
- OBSClient.dll
SetEnabledAsync(bool, CancellationToken)
Shows or hides the scene item, and returns when the model shows it.
public Task SetEnabledAsync(bool value, CancellationToken cancellationToken = default)
Parameters
valueboolTrue to show the item, false to hide it.
cancellationTokenCancellationTokenA token that ends the wait. A change that was not sent yet is not sent.
Returns
- Task
A task that completes when IsEnabled is
value, or when the model has been read again after the events did not show it.
Remarks
The changes that you ask for are made one at a time, in the order in which you asked for them. OBS Studio announces a change with an event, which can come a few milliseconds after its answer: the task completes when IsEnabled says what you asked for, so that what you read next is what you changed. When you ask for several changes of the same scene one after the other without waiting for each, the model shows them one after the other, and each task completes when the model shows its change after the changes before it (not when it shows the same value from before them). When the event does not come within ConfirmationTimeout, the model reads the scene items of the scene, and the task completes with what OBS Studio holds then (somebody else may have changed it again). When OBS Studio changes its scene collection before the model shows the change, the task completes too: the change was made in the collection that was left, and this object is Gone by then. When the model can not be read again in time either, the task ends with an ObsNotConfirmedException: OBS Studio made the change, and the model does not show it yet.
A token that ends before the request is sent keeps it from being sent. After that the change is not undone: OBS Studio may still make it, and the model follows it through the events. The next change waits until OBS Studio has answered this one (at most WriteTimeout), whether the token ended or not, so that the changes are made in the order in which you asked for them.
Exceptions
- ObsRemovedException
The scene item, or its scene, was removed.
- ObsNotConnectedException
There is no connection to OBS Studio, or the connection that the change was asked for on has ended and another was made. Nothing was changed.
- ObsNotReadyException
OBS Studio is changing its scene collection, or did so after the call. 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.