111,097
社区成员




private void Frm_Load(object sender, EventArgs e)
{
flashThread = new Thread(new ThreadStart(this.flash_doing));
flashThread.Name = "刷新";
flashThread.IsBackground = true;
flashThread.Start(); //启动线程
}
private void flash_doing()
{
while (true)
{
StartFlash();
System.Threading.Thread.Sleep(15*1000); //测试15秒刷新一次
}
}
private void StartFlash()
{
if (this.InvokeRequired)
{
doCallback d = new doCallback(ShowFrm);
this.Invoke(d);
}
}
private void ShowFrm()
{
//刷新页面
}
private Connection DbCon = null;
private PreparedStatement prepState;
private CallableStatement callState;
private ResultSet DbResult;
public void close() {
try {
if (DbResult != null) {
DbResult.close();
DbResult = null;
}
} catch (Exception e) {
System.err.println("Error on close ResultSet " + e.getMessage());
}
try {
if (prepState != null) {
prepState.close();
prepState = null;
}
} catch (Exception e) {
System.err.println("Error on close PreparedStatement" + e.getMessage());
}
try {
if (callState != null) {
callState.close();
callState = null;
}
} catch (Exception e) {
System.err.println("Error on close CallableStatement " + e.getMessage());
}
try {
boolean autoCommit = true;
try {
autoCommit = DbCon.getAutoCommit();
} catch (Exception ea) {
}
if (DbCon != null && autoCommit == true) {
DbCon.close();
DbCon = null;
}
} catch (Exception e) {
System.err.println("Error on close Connection " + e.getMessage());
}
}