void loop() { while (true) { if (cancellationTokenSource.Token.IsCancellationRequested) { DispatcherHelper.Execute(() => { State = InputStreamState.Stopped; CommandManager.InvalidateRequerySuggested(); }); return; } streamService.SendStreamText(randomText.GetRandomString()); Thread.Sleep(2500); } }
public void Stop() { form.Stop(); State = InputStreamState.Stopped; }
public void Start() { form.Start(); State = InputStreamState.Started; }
public void Stop() { State = InputStreamState.Stopping; cancellationTokenSource.Cancel(); }
public void Start() { cancellationTokenSource = new CancellationTokenSource(); loopTask = Task.Factory.StartNew(loop, cancellationTokenSource.Token); State = InputStreamState.Started; }