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 and trainer specializing in software best practices using Microsoft tools. Ben’s main areas of emphasis include Team Foundation Server, Scrum, software testing, and software architecture. He is a Microsoft Visual Studio ALM MVP, a certified Scrum trainer via Scrum.org, and a speaker at conferences such as TechEd and Visual Studio Live! When not developing software, Ben’s been known to go running and sea kayaking in order to balance out his love of cheese, cured meats, and champagne. He can be contacted via www.benday.com.

comments powered by Disqus

Featured

  • Entity Framework Core 6: What Developers Want

    Microsoft outlined its plan for Entity Framework Core 6, which in November will take its place as the data access component of the landmark .NET 6, a long-term support (LTS) release that will mark Microsoft's transition from the Windows-only .NET Framework to an open source, cross-platform umbrella offering of all things .NET.

  • AWS Open Sources .NET Porting Assistant GUI

    After previously open sourcing components of its Porting Assistant for .NET, Amazon Web Services open sourced the tool's GUI.

  • .NET Core Ranks High Among Frameworks in New Dev Survey

    .NET Core placed high in a web-dominated ranking of development frameworks published by CodinGame, which provides a tech hiring platform.

  • Here's a One-Stop Shop for .NET 5 Improvements

    Culled from reams of Microsoft documentation, here's a high-level summary of what's new for performance, networking, diagnostics and more, along with links to the nitty-gritty details for those wanting to dig in more.

Upcoming Events