method
cref: M:Microsoft.UI.Reactor.Core.RenderContext.UseState``1(``0,System.Boolean)
Learn more: Hooks, Effects
Declares a piece of state. Returns (currentValue, setter).
Must be called in the same order every render (just like React hooks).
When is true, reads and writes are synchronized
with a per-hook lock so concurrent setter calls from many threads serialize.
When false (default), cross-thread setter calls are auto-marshaled onto the
captured UI dispatcher — the write and the rerender both run on the UI thread,
so background-thread setters from Task.Run, PeriodicTimer, or
callbacks after await … ConfigureAwait(false) work correctly without
any extra opt-in. Use : true when you need
many concurrent setters to apply in-place (i.e., without an intervening UI
thread hop) or when the setter result must be visible to its caller before
the next UI tick.