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

  • Build Your First AI Applications with Local AI

    "AI right now feels like a vast space which can be hard to jump into," says Craig Loewen, a senior product manager at Microsoft who is helping devs unsure about making that first daunting leap.

  • On Blazor Component Reusability - From Day 0

    "We want to try to design from Day One, even Day Zero, with reusability in mind," says Blazor expert Allen Conway in imparting his expertise to an audience of hundreds in an online tech event on Tuesday.

  • Decision Tree Regression from Scratch Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of decision tree regression using the C# language. Unlike most implementations, this one does not use recursion or pointers, which makes the code easy to understand and modify.

  • Visual Studio's AI Future: Copilot .NET Upgrades and More

    At this week's Microsoft Ignite conference, the Visual Studio team showed off a future AI-powered IDE that will leverage GitHub Copilot for legacy app .NET upgrades, along with several more cutting-edge features.

  • PowerShell Gets AI-ified in 'AI Shell' Preview

    Eschewing the term "Copilot," Microsoft introduced a new AI-powered tool for PowerShell called "AI Shell," available in preview.

Subscribe on YouTube