Click here to Skip to main content
15,922,419 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,
I have problem with Channel Factory. After I complete operation, I want to close channel.
IClinetChannel.Close()take too much time (more than 3 minutes). Can you please guide why this behavior. What is suitable way to close Channel

Bellow is sample code

C#
  IAdminServiceTEMP srvTmp = Core.ServiceModel.ChannelFactory.CreateChannel<IAdminServiceTEMP>();
                Task<GenericResponse<BTCH_DETLInfo>>.Factory.FromAsync(srvTmp.BeginReadContractBatchData, srvTmp.EndReadContractBatchData, request, TaskCreationOptions.None)
                    .ContinueWith(resp =>
                    {
                        if (resp != null)
                        {
                            cmsBatchDetail = resp.Result.ResultSet;
                        }
                    }).Wait();


//Bellow code for close channel take lot of time for closing current Channel;
                Core.ServiceModel.ChannelFactory.CloseChannel();


C#
//Code for closing channel
IClientChannel channel = m_channel[factoryNme] as IClientChannel;
                    if (channel == null) return;
                    try
                    {
                        if (channel.State == CommunicationState.Faulted)
                        {
                            channel.Abort();
                        }
                        channel.Close();


                    }
                    catch
                    {
                        channel.Abort();
                    }
Posted

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900