Click here to Skip to main content
15,885,216 members
Articles / Desktop Programming / WPF

How to Call WCF Services Synchronously and Asynchronously

Rate me:
Please Sign up or sign in to vote.
4.91/5 (48 votes)
16 Jul 2010CPOL9 min read 297.2K   9.1K   167  
This article is an example to show you how to call WCF services synchronously as well as asynchronously.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WFCCallExample.Properties;


namespace WFCCallExample
{
    /// <summary>
    /// Interaction logic for MainWnd.xaml
    /// </summary>
    public partial class MainWnd : Window
    {
        public MainWnd()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(MainWnd_Loaded);
        }

        void MainWnd_Loaded(object sender, RoutedEventArgs e)
        {
            DataContext = Settings.Default;

            ((TabItem)ApplicationMainTab.Items[0]).Content
                = new WCFCallExample(false);

            ((TabItem)ApplicationMainTab.Items[1]).Content
                = new WCFCallExample(true);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
I have been working in the IT industry for some time. It is still exciting and I am still learning. I am a happy and honest person, and I want to be your friend.

Comments and Discussions