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 829 B

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