6 Tips of Separation: Listing 1.

Asynchronous calls to a WCF service.

public void LoadById(int id)
{
  // Create an instance of the service proxy
  var client = new PersonService.PersonServiceClient();
  // Subscribe to the "completed" event for the service method
  client.LoadByIdCompleted += 
    new EventHandler<PersonService.LoadByIdCompletedEventArgs>(
           client_LoadByIdCompleted);
  // Call the service method
  client.LoadByIdAsync(id);
}

void client_LoadByIdCompleted(object sender, 
    PersonService.LoadByIdCompletedEventArgs e)
{
  // This method is called after the call to LoadByIdAsync() is finished
  PersonService.PersonDtopersonReturnedByService = e.Result;
  // ...
}

About the Author

Benjamin Day is a consultant, trainer, and author specializing in software development, project management, and leadership. Ben’s main areas of emphasis include Azure DevOps, C#, Angular, Scrum, software testing, and software architecture. He is a Microsoft MVP, a certified Scrum trainer via Scrum.org, and speaks regularly at VSLive. His online courses are available at YouTube and at http://www.pluralsight.com. Ben is also the founder of https://SlideSpeaker.ai. He can be contacted via http://www.benday.com.

comments powered by Disqus

Featured

  • The AI-Powered Software Development Lifecycle

    René van Osnabrugge makes the case that AI's biggest opportunity in software development is not faster coding -- it's reducing the friction everywhere else in the SDLC.

  • Copilot Usage-Based Billing Gets a Token Dashboard

    Microsoft is keeping Visual Studio's new built-in Agent Skills switched off by default while a public dashboard measures whether their performance gains justify the additional tokens they may consume.

  • VS Code 1.129 Introduces Agent Host and Experimental Agents Window Editor

    Visual Studio Code 1.129 adds a dedicated process for running AI agent sessions and an experimental docked editor for reviewing agent-generated changes.

  • .NET 11 Preview 6 Roundup: ASP.NET Core, MAUI, C#, EF Core and SDK Updates

    Microsoft's sixth .NET 11 preview advances async validation, C# unions, cross-platform UI controls, database queries, testing tools, Native AOT and container images.

Subscribe on YouTube