Exemple #1
0
 static async Task WriterText(NatsConnection connection, CancellationToken cancellationToken)
 {
     while (!cancellationToken.IsCancellationRequested)
     {
         await connection.PublishTextAsync("HELLO", "HELLO WORLD", cancellationToken : cancellationToken);
     }
 }
Exemple #2
0
        static async Task SenderTask(NatsConnection connection, CancellationToken cancellationToken)
        {
            // Not very efficient, but it's the idea ;)
            var sb = new StringBuilder();

            while (sb.Length < 900_000)
            {
                sb.Append((sb.Length % 10).ToString());
            }

            var str = sb.ToString();

            Console.WriteLine("Sending string {0} characters long", str.Length);
            await connection.PublishTextAsync("long.message", str, cancellationToken : cancellationToken);
        }