public virtual void StartTransfer(Boxerp.Client.ResponsiveEnum trType)
        {
            _transferType = trType;
            try
            {
                if (_threadsPoolHash.Count != 0)
                {
                    // busy, show an error message
                }

                List<MethodInfo> methods = this.GetResponsiveMethods(_transferType);
                if (methods.Count == 0)
                {
                    throw new NullReferenceException("No private/protected responsive methods found");
                }

                _asyncCallsCount = methods.Count;

                foreach (MethodInfo method in methods)
                {

                    ThreadStart methodStart = new SimpleInvoker(method, this).Invoke;
                    Thread methodThread = new Thread(methodStart);
                    methodThread.Start();
                    _threadsPoolHash[methodThread.ManagedThreadId] = methodThread;
                    //method.Invoke(this, null); // execute method
                }
            }
            catch (TargetInvocationException ex)
            {
                Console.WriteLine("One responsive method raises exception:" + ex.Message+ ex.StackTrace);
                throw ex;
            }
            catch(Exception ex)
            {
                throw ex;
            }
            // TODO : Write the code to stop threads
        }
 /// <summary>
 /// Pick up all methods marked with the ResponsiveAttribute
 /// </summary>
 /// <param name="trType"></param>
 /// <param name="controller"></param>
 /// <returns></returns>
 private List<System.Reflection.MethodInfo> GetResponsiveMethods(ResponsiveEnum trType, IController controller)
 {
     List<MethodInfo> responsiveMethods = new List<MethodInfo>();
     MethodInfo[] methods = controller.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance);
     foreach(MethodInfo method in methods)
     {
         object[] attributes = method.GetCustomAttributes(typeof(ResponsiveAttribute), true);
         if (attributes.Length != 0)
         {
             ResponsiveAttribute att = (ResponsiveAttribute)attributes[0];
             if (att.RespType == trType)
             {
                 // TODO: Search within method code calls to OnAbortRemoteCall, OnRemoteException, StopTransfer: Cecil?
                 responsiveMethods.Add(method);
             }
         }
     }
     return responsiveMethods;
 }
 public ResponsiveAttribute(ResponsiveEnum rType)
 {
     respType = rType;
 }
 public override void StartTransfer(ResponsiveEnum transferType)
 {
     if (parentWindow != null)
     {
         waitDialog = new WaitDialog(parentWindow);
     }
     else
     {
         waitDialog = new WaitDialog();
     }
     waitDialog.CancelEvent += OnCancel;
     transferSuccess = true;
     base.StartTransfer(transferType);
 }
 private void ProcessAsyncCall(SimpleDelegate method)
 {
     try
     {
         _transferType = ResponsiveEnum.Other;
         _asyncCallsCount++; // = 1;
         ThreadStart methodStart = new SimpleInvoker(method).Invoke;
         Thread methodThread = new Thread(methodStart);
         methodThread.Start();
         _threadsPoolHash[methodThread.ManagedThreadId] = methodThread;
     }
     catch (TargetInvocationException ex)
     {
         Console.WriteLine("responsive method raises exception:" + ex.Message+ ex.StackTrace);
         throw ex;
     }
     catch(Exception ex)
     {
         throw ex;
     }
     finally
     {
     }
 }