当前位置: 首页>>代码示例>>C#>>正文


C# ISender.CloseSender方法代码示例

本文整理汇总了C#中ISender.CloseSender方法的典型用法代码示例。如果您正苦于以下问题:C# ISender.CloseSender方法的具体用法?C# ISender.CloseSender怎么用?C# ISender.CloseSender使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISender的用法示例。


在下文中一共展示了ISender.CloseSender方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Transmit


//.........这里部分代码省略.........
                            catch (Exception Ex)
                            {
                                Logger.Error("EventTransmitter", "Transmit", Ex);
                                Logger.Info("EventTransmitter", "Transmit", "Error in message:" + strXML);

                                if (Settings.DeleteMessageOnParseErr == 1)
                                {
                                    Logger.Error("EventTransmitter", "Transmit", "Committing Queue[DeleteMessageOnParseErr]");
                                    _Message.Commit();
                                    continue;
                                }
                                _evtTransmitShutDown.WaitOne(5000);
                            }
                            int iRetryOnNWErr = 0;
                            do
                            {
                                if (_evtTransmitShutDown.WaitOne(50))
                                {
                                    break;
                                }

                                try
                                {
                                    if (iRetryOnNWErr >= Settings.iMaxTransmissionRetry)
                                    {
                                        //Close transmission when maximum retry reached 
                                        throw new Exception(String.Format("Stopping Transmision after Retrying [{0}] times. ", iRetryOnNWErr.ToString()));
                                    }
                                    else
                                    {

                                        //transmit message to server 
                                        iResponse = _Sender.Send(_MessageFormatter);
                                         Logger.Debug("Response from Server: " +  iResponse.ToString());
                                        if (iResponse > 0)// to be checked && msg.SequenceNo == bSequenceNo)// ACK
                                        {
                                             
                                            //Set retry value to MAX+1 to quit loop 
                                            iRetryOnNWErr = Settings.iMaxTransmissionRetry + 1;
                                            //Commiting Queue read After succesfull Transaction 
                                            Logger.Info("Committing Queue");
                                            _Message.Commit();
                                        }
                                            
                                        else if (iResponse==0)
                                        {
                                            Logger.Info("Response from Server [0] Message not processed at server");
                                            //Set retry value to MAX+1 to quit loop 
                                            iRetryOnNWErr = Settings.iMaxTransmissionRetry + 1;
                                            //Commiting Queue read After succesfull Transaction 
                                            Logger.Info("Committing Queue");
                                            _Message.Commit();
                                        }
                                        else
                                        {
                                           
                                            if (Settings.EventTransmit_RetryRepeat == 0)
                                            {
                                                iRetryOnNWErr++;
                                                Logger.Info(string.Format("Retrying to send message (Attempt[{0}]) ", iRetryOnNWErr.ToString()));
                                            }
                                            else
                                            {
                                                Logger.Info("Retrying to send message");
                                                iRetryOnNWErr = 0;
                                            }
                                        }
                                    }
                                }
                                catch (Exception Ex1)
                                {
                                    _evtTransmitShutDown.WaitOne(5000);
                                    Logger.Error("EventTransmitter", "Transmit", Ex1);
                                    //refresh connection and retry till configured number of times 
                                    iRetryOnNWErr++;
                                    _Sender.CloseSender();
                                    _IsTransmitting = false;
                                    _Sender.Initialize(Settings.STMServerIP, Settings.STMServerPort);
                                }
                            } while (iRetryOnNWErr <= Settings.iMaxTransmissionRetry);
                        

                    }
                }
            }
            catch (Exception Ex)
            {
                Logger.Error("EventTransmitter", "Transmit", Ex.Message);
                if (Settings.EventTransmit_RecoverOnError != 0)
                {
                    _evtTransmitShutDown.WaitOne(2000);
                    this.Transmit();
                }
            }
            finally
            {
                this.CloseTransmission(); 
            }
           
        }
开发者ID:sreenandini,项目名称:test_buildscripts,代码行数:101,代码来源:EventTransmitter.cs


注:本文中的ISender.CloseSender方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。