Click here to Skip to main content
15,894,646 members
Articles / Programming Languages / C#

WCF: Duplex Operations and UI Threads

Rate me:
Please Sign up or sign in to vote.
4.91/5 (162 votes)
20 Feb 2007CPOL7 min read 532.2K   9.9K   286  
This article examines how duplex operations are implemented in WCF as well as some of the issues that may arise when dealing with UI threads.
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.42
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace BeerClient.BeerInventoryGateway
{
    
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(Namespace="http://jeffbarnes.net/wcf/samples/client_callback/BeerInventoryService/", ConfigurationName="BeerClient.BeerInventoryGateway.BeerInventoryService", CallbackContract=typeof(BeerClient.BeerInventoryGateway.BeerInventoryServiceCallback), SessionMode=System.ServiceModel.SessionMode.Required)]
    public interface BeerInventoryService
    {
        
        [System.ServiceModel.OperationContractAttribute(Action="http://jeffbarnes.net/wcf/samples/client_callback/BeerInventoryService/BeerInvent" +
            "oryService/JoinTheParty", ReplyAction="http://jeffbarnes.net/wcf/samples/client_callback/BeerInventoryService/BeerInvent" +
            "oryService/JoinThePartyResponse")]
        int JoinTheParty(string guestName);
        
        [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://jeffbarnes.net/wcf/samples/client_callback/BeerInventoryService/BeerInvent" +
            "oryService/MakeBeerRun")]
        void MakeBeerRun(string guestName, int numberOfBeers);
        
        [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://jeffbarnes.net/wcf/samples/client_callback/BeerInventoryService/BeerInvent" +
            "oryService/DrinkBeer")]
        void DrinkBeer(string guestName);
        
        [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://jeffbarnes.net/wcf/samples/client_callback/BeerInventoryService/BeerInvent" +
            "oryService/LeaveTheParty")]
        void LeaveTheParty(string guestName);
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public interface BeerInventoryServiceCallback
    {
        
        [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://jeffbarnes.net/wcf/samples/client_callback/BeerInventoryService/BeerInvent" +
            "oryService/NotifyGuestJoinedParty")]
        void NotifyGuestJoinedParty(string guestName);
        
        [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://jeffbarnes.net/wcf/samples/client_callback/BeerInventoryService/BeerInvent" +
            "oryService/NotifyBeerInventoryChanged")]
        void NotifyBeerInventoryChanged(string guestName, int numberOfBeers);
        
        [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://jeffbarnes.net/wcf/samples/client_callback/BeerInventoryService/BeerInvent" +
            "oryService/NotifyGuestLeftParty")]
        void NotifyGuestLeftParty(string guestName);
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public interface BeerInventoryServiceChannel : BeerClient.BeerInventoryGateway.BeerInventoryService, System.ServiceModel.IClientChannel
    {
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public partial class BeerInventoryServiceClient : System.ServiceModel.DuplexClientBase<BeerClient.BeerInventoryGateway.BeerInventoryService>, BeerClient.BeerInventoryGateway.BeerInventoryService
    {
        
        public BeerInventoryServiceClient(System.ServiceModel.InstanceContext callbackInstance) : 
                base(callbackInstance)
        {
        }
        
        public BeerInventoryServiceClient(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName) : 
                base(callbackInstance, endpointConfigurationName)
        {
        }
        
        public BeerInventoryServiceClient(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName, string remoteAddress) : 
                base(callbackInstance, endpointConfigurationName, remoteAddress)
        {
        }
        
        public BeerInventoryServiceClient(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(callbackInstance, endpointConfigurationName, remoteAddress)
        {
        }
        
        public BeerInventoryServiceClient(System.ServiceModel.InstanceContext callbackInstance, System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(callbackInstance, binding, remoteAddress)
        {
        }
        
        public int JoinTheParty(string guestName)
        {
            return base.Channel.JoinTheParty(guestName);
        }
        
        public void MakeBeerRun(string guestName, int numberOfBeers)
        {
            base.Channel.MakeBeerRun(guestName, numberOfBeers);
        }
        
        public void DrinkBeer(string guestName)
        {
            base.Channel.DrinkBeer(guestName);
        }
        
        public void LeaveTheParty(string guestName)
        {
            base.Channel.LeaveTheParty(guestName);
        }
    }
}

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
Software Developer (Senior)
United States United States
I'm a passionate software developer and advocate of the Microsoft .NET platform. In my opinion, software development is a craft that necessitates a conscious effort to continually improve your skills rather than falling into the trap of complacency. I was also awarded as a Microsoft MVP in Connected Systems in 2008, 2009, and 2010.

Comments and Discussions