private void MessageGenerator_OnStopCalled(object sender, EventArgs e) { IsGeneratingMessages = false; var message = new TestMessage() { Content = "Stop Message", Subject = "Messages have been stopped" }; OnMessageGenerated?.Invoke(this, new MessageGeneratedEventArgs(message)); }
private async Task Generate() { while (!Token.IsCancellationRequested) { var message = new TestMessage() { Content = "Test message generated", Subject = "Test Message" }; OnMessageGenerated?.Invoke(this, new MessageGeneratedEventArgs(message)); await Task.Delay(2000); } }