상속: System.EventArgs
예제 #1
0
 protected override void OnAsyncOperationFinish(Object sender, ThreadEventArgs args)
 {
     if ((args.Success) && (args.MethodBase == Method(runMethod)))
     {
         _control.ShowSomething();
     }
 }
예제 #2
0
 protected override void OnAsyncOperationFinish(Object sender, ThreadEventArgs args)
 {
     if ((args.Success) && (args.MethodBase == MethodBase(runMethod)))
     {
         _view.ShowSomething();
     }
     if ((args.Success) && (args.MethodBase == MethodBase(runMethodWithCancellationLogic)))
     {
         _view.ShowSomething();
     }
 }
        /// <summary>
        /// As the async op is completed, the editUserWindow must be hidden.
        /// </summary>
        public override void OnAsyncCallStop(object sender, ThreadEventArgs teargs)
        {
            SimpleDelegate saveUser = this.SaveUser;

            if (saveUser.Method == teargs.MethodBase)
            {
                int userId = (int)teargs.ReturnValue;
                if (userId > 0)
                {
                    base.parentWindow.Destroy();
                }
            }
        }
        public override void OnAsyncCallStop(object sender, ThreadEventArgs teargs)
        {
            Console.WriteLine("ASYNC CALL STOP");
            Console.WriteLine("{0},{1},{2}", teargs.ThreadId, teargs.MethodBase.ToString(), teargs.ReturnValue);
            SimpleDelegate deleteUser = this.DeleteUser;

            if (deleteUser.Method == teargs.MethodBase)
            {
                int userId = (int)teargs.ReturnValue;
                if (userId > 0)
                {
                    Console.WriteLine("userid = " + userId);
                    ftreeviewUsers.DeleteModelById(userId);
                }
            }
        }
        /// <summary>
        /// Take the first block of threads from the queue and remove it from the queue. 
        /// The contents of the block are the threads created by StartAsyncCall or StartAsyncCallList
        /// When all the threads from that block have finished invoke OnTransferCompleted to access the GUI
        /// </summary>
        /// <param name="args"></param>
        /// <param name="output"></param>
        private void StopAsyncMethod(ThreadEventArgs args, object output)
        {
            lock(_innerLock)
            {
                if (_threadDictionariesList.Count == 0)
                {
                    throw new Exception("Error trying to stop asynchronous call. You are most likely calling StopAsyncMethod more than once");
                }
                else
                {
                    Console.Out.WriteLine("*** stopping: " + _threadDictionariesList.Count);
                    for (int i = 0; i < _threadDictionariesList.Count; i++)
                    {
                        Dictionary<int, Thread> threadBlock = _threadDictionariesList[i];
                        if (threadBlock.ContainsKey(args.ThreadId))
                        {
                            Console.Out.WriteLine("threadBlog count:" + threadBlock.Count + "," + Thread.CurrentThread.ManagedThreadId);
                            if (threadBlock.Count > 0)
                            {
                                threadBlock.Remove(args.ThreadId);
                                _cancelRequests.Remove(args.ThreadId);
                                // FIXME: doing this, the args is populated with the last thread results,
                                // loosing the previous ones if the operation launched a group of threads
                                // in parallell
                                args.Success = args.Success && _operationSucess[args.ThreadId];
                                _operationSucess.Remove(args.ThreadId); ;
                                args.OperationType = _operationTypes[args.ThreadId];
                                _operationTypes.Remove(args.ThreadId); ;
                                args.ExceptionMsg += _exceptions[args.ThreadId];
                                _exceptions.Remove(args.ThreadId);

                                Console.Out.WriteLine("  now after removing:" + threadBlock.Count);
                                if (threadBlock.Count == 0)
                                {
                                    Console.Out.WriteLine("DEQUEUING DATA FROM STORAGE:" + Thread.CurrentThread.ManagedThreadId);
                                    _threadDictionariesList.RemoveAt(i);
                                    OnTransferCompleted(args.OperationType, args);
                                    break;
                                }
                            }
                        }
                    }

                }
            }
        }
 /// <summary>
 /// Stops the current thread passing in information about the thread itself, and any outcome information
 /// </summary>
 /// <param name="threadId">You can use the CurrentThread Abstract Controller's property or System.Threading.Thread.CurrentThread.ManagedThreadId</param>
 /// <param name="method">The method which is running. You can pass the method if its signature matches the SimpleDelegate</param>
 /// <param name="output">Any info you want to send. It could be a message, an exception or whatever you need</param>
 public void StopAsyncMethod(int threadId, SimpleDelegate method, object output)
 {
     ThreadEventArgs tea = new ThreadEventArgs(threadId, method, output);
     StopAsyncMethod(tea, output);
 }
 /// <summary>
 /// Stops the current thread passing in information about the thread itself, and any outcome information
 /// </summary>
 /// <param name="threadId">You can use the CurrentThread Abstract Controller's property or System.Threading.Thread.CurrentThread.ManagedThreadId</param>
 /// <param name="methodBase">The method who is running. You can call MethodBase(method), implemented in the Abstract Controller</param>
 /// <param name="output">Any info you want to send. It could be a message, an exception or whatever you need</param>
 public void StopAsyncMethod(int threadId, MethodBase methodBase, object output)
 {
     ThreadEventArgs tea = new ThreadEventArgs(threadId, methodBase, output);
     StopAsyncMethod(tea, output);
 }
 public abstract void OnTransferCompleted(object sender, ThreadEventArgs e);
예제 #9
0
 protected override void OnAsyncOperationFinish(object sender, ThreadEventArgs args)
 {
     _control.ShowMessage("OK!!!");
 }
        public void StopTransfer(int threadId, MethodBase methodBase, object output)
        {
            lock(this)
            {
                if (_asyncCallsCount > 0)
                {
                    _asyncCallsCount --;
                    if (_asyncCallsCount == 0)
                    {
                        _threadsPoolHash.Clear();
                        if (_baseTransferCompleteHandler != null)
                        {
                            ThreadEventArgs tea = new ThreadEventArgs(threadId, methodBase, output);
                            Delegate[] invList = _baseTransferCompleteHandler.GetInvocationList();
                            if (invList.Length > 0)
                            {
                                object[] parameters = { _transferType, tea };
                                invList[0].DynamicInvoke(parameters);

                                //_baseTransferCompleteHandler(_transferType, tea);
                            }
                            else
                            {
                                throw new NullReferenceException("BaseTransferCompleteEvent has no handler");
                            }
                        }
                    }
                }
            }
        }