//异步访问控件 private void SetLableText(string msg) { if (lblProgress.InvokeRequired) { var set = new SetProcess(SetLableText); //委托的方法参数应和SetCalResult一致 //此方法第二参数用于传入方法,代替形参result lblProgress.Invoke(set, new object[] { msg }); } else { lblProgress.Text = msg; } }
private void Execute() { if (_commandIndex >= ProcessContext.Request.Commands.Length) { FinishExecute(); return; } var command = ProcessContext.Request.Commands[_commandIndex]; try { switch (command.Type) { case CommandType.ReleaseConnection: ReleaseConnectionProcess.Execute(this, command as ReleaseConnectionCommand); break; case CommandType.OpenTransaction: OpenTransactionProcess.Execute(this, command as OpenTransactionCommand); break; case CommandType.CommitTransaction: CommitTransactionProcess.Execute(this, command as CommitTransactionCommand); break; case CommandType.RollbackTransaction: RollbackTransactionProcess.Execute(this, command as RollbackTransactionCommand); break; case CommandType.WithDatabase: WithDatabaseProcess.Execute(this, command as WithDatabaseCommand); break; case CommandType.WithTable: WithTableProcess.Execute(this, command as WithTableCommand); break; case CommandType.Set: SetProcess.Execute(this, command as SetCommand); break; case CommandType.Select: SelectProcess.Execute(this, command as SelectCommand); break; } } catch (Exception err) { HandleExecuteError(err); } }
//异步访问控件 private void SetLableText(string msg) { if (lblProgress.InvokeRequired) { var set = new SetProcess(SetLableText); //委托的方法参数应和SetCalResult一致 //此方法第二参数用于传入方法,代替形参result lblProgress.Invoke(set, new object[] { msg }); } else { lblProgress.Text = msg; } }