+ Reply to Thread
Results 1 to 2 of 2

Thread: close WCF 4 channels

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    10

    close WCF 4 channels

    Hello , i`d like to close WCF 4 channels but i need the correct way to do that !!

    Thanks in advance .

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    16
    There is always a way , please check the below code :
    Code:
    ChannelFactory<IMyService> channelFactory = null;
    try
    {
        channelFactory =
            new ChannelFactory<IMyService>();
        channelFactory.Open();
        // do anything here
        channelFactory.Close();
    }
    catch (CommunicationException)
    {
        if (channelFactory != null)
        {
            channelFactory.Abort();
        }
    }
    catch (TimeoutException)
    {
        if (channelFactory != null)
        {
            channelFactory.Abort();
        }
    }
    catch (Exception)
    {
        if (channelFactory != null)
        {
            channelFactory.Abort();
        }
        throw;
    }

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts