@using System.Threading.Tasks
@state
@functions { TaskCompletionSource _tcs; string state = "Stopped"; Task Tick(UIMouseEventArgs e) { if (_tcs == null) { _tcs = new TaskCompletionSource(); state = "Started"; return _tcs.Task.ContinueWith((task) => { state = "Stopped"; _tcs = null; }); } return Task.CompletedTask; } void Tock(UIMouseEventArgs e) { _tcs.TrySetResult(null); } }