You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Program.cs 797 B

12345678910111213141516
  1. // Copyright (c) Microsoft Corporation. All rights reserved.
  2. // Program.cs
  3. using Microsoft.AutoGen.Contracts;
  4. using Microsoft.AutoGen.Core;
  5. using Samples;
  6. // Set up app builder for in-process runtime, allow message delivery to self, and add the Hello agent
  7. AgentsAppBuilder appBuilder = new AgentsAppBuilder()
  8. .UseInProcessRuntime(deliverToSelf: true)
  9. .AddAgent<HelloAgent>("HelloAgent");
  10. var app = await appBuilder.BuildAsync(); // Build the app
  11. // Create a custom message type from proto and define message
  12. NewMessageReceived message = new NewMessageReceived { Message = "Hello World!" };
  13. await app.PublishMessageAsync(message, new TopicId("HelloTopic")); // Publish custom message (handler has been set in HelloAgent)
  14. await app.WaitForShutdownAsync(); // Wait for shutdown from agent