示例#1
0
        public void ProcessRun()
        {
            PokeBall args = new PokeBall();

            // 同步
            if (!_IsProcessRunAsync)
            {
                try {
                    if (RunBefore(args) == ResultStatus.Success)
                    {
                        if (Run(args) == ResultStatus.Success)
                        {
                            RunAfter(args);
                        }
                    }
                } catch (Exception ex) {
                    WriteLog(ex);
                }
            }
            // 非同步
            else
            {
                if (RunBefore(args) == ResultStatus.Success)
                {
                    AsyncHelper.DoWorkAsync(() => {
                        return(Run(args));
                    },
                                            (result) => {
                        if (result == ResultStatus.Success)
                        {
                            this.BeginInvoke(new MethodInvoker(() => {
                                RunAfter(args);
                            }));
                        }
                    },
                                            (exception) => {
                        MessageBox.Show(exception.Message);
                    });
                }
            }
        }