public void HandlerCount()
 {
     if (OnResponseAdd != null)
     {
         log4j.Info("OnResponseAdd.count: " + OnResponseAdd.GetInvocationList().Count());
     }
     else
     {
         log4j.Info("OnResponseAdd empty");
     }
 }
        protected void Init()
        {
            On <Data.ResponseAdd>(Data.Cmd.TcsCommand.ResponseAdd.ToString(), (data) =>
            {
                // when received data ResponseAdd from server
                //log4j.Info("OnResponseAdd: " + data.Result);
                //OnResponseAdd?.Invoke(data);

                // test BeginInvoke
                if (OnResponseAdd != null)
                {
                    Delegate[] eventListeners = OnResponseAdd.GetInvocationList();
                    for (int i = 0; i < eventListeners.Length; i++)
                    {
                        ResponseAddHandler methodToInvoke = (ResponseAddHandler)eventListeners[i];
                        methodToInvoke.BeginInvoke(data, (iar) =>
                        {
                            log4j.Info("endInvoke");
                            var ar           = (System.Runtime.Remoting.Messaging.AsyncResult)iar;
                            var invokeMethod = (ResponseAddHandler)ar.AsyncDelegate;
                            try
                            {
                                invokeMethod.EndInvoke(iar);
                            }
                            catch (Exception ex)
                            {
                                log4j.Error(invokeMethod.ToString(), ex);
                            }
                        }, null);
                    }
                }

                /// cannot use this (must use GetInvocationList())
                //OnResponseAdd?.BeginInvoke(data, (iar) =>
                //{
                //    log4j.Info("endInvoke");
                //    var ar = (System.Runtime.Remoting.Messaging.AsyncResult)iar;
                //    var invokeMethod = (ResponseAddHandler)ar.AsyncDelegate;
                //    try
                //    {
                //        invokeMethod.EndInvoke(iar);
                //    }
                //    catch (Exception ex)
                //    {
                //        log4j.Error(invokeMethod.ToString(), ex);
                //    }
                //}, null);
            });

            On <Data.ResponseEcho>(Data.Cmd.TcsCommand.ResponseEcho.ToString(), (data) =>
            {
                OnResponseEcho?.Invoke(data);
            });
        }