MS Access中的多线程,异步处理 [英] multi-thread in MS Access, async processing

查看:64
本文介绍了MS Access中的多线程,异步处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道标题听起来很疯狂,但这是我的情况.

I know that title sounds crazy but here is my situation.

在某个用户事件之后,我需要更新几个与用户当前正在执行的无关"的表.当前,这需要花费几秒钟的时间来执行,并且会使用户感到一定程度的沮丧.有没有办法在第二个过程中执行我的更新,或者以一种不会在处理过程中冻结"我的应用程序UI的方式来执行更新?

After a certain user event I need to update a couple tables that are "unrelated" to what the user is currently doing. Currently this takes a couple seconds to execute and causes the user a certain amount of frustration. Is there a way to perform my update in a second process or in a manner that doesn't "freeze" the UI of my app while it is processing?

谢谢

推荐答案

我将着手解决问题的核心-调整数据更新查询以使其运行更快.

I would work on the heart of the problem - Tune the data update queries to run faster.

话虽如此,MS Access不支持多线程.

Having said that, MS Access does not support multi-threading.

因此,当您对某个过程进行阻塞调用时,MS Access将冻结屏幕,直到调用返回.

So, when you make a blocking call to a procedure, MS Access will freeze the screen until the call returns.

修改

如果您正在通过缓慢的网络连接更新大型表,那么DAO并不是您真正的好朋友.您可能要考虑切换到使用ODBC连接并运行经过优化的更新语句.

DAO isn't really your best friend if you are updating a large table over a slow network connection. You might want to consider switching to using an ODBC connection and running a optimized update statement.

修改2

使用ODBC时,必须编写ADO样式代码才能使此工作生效.请注意,此示例此代码是OTTOMH.

when you use ODBC, you have to write ADO style code to make this work. Note this sample this code is OTTOMH.

dim myConn as ADODB.Connection
dim myCmd as ADODB.Command

set myConn = new ADODB.Connection
myConn.ConnectionString = "Provider=SQLOLEDB;Server=MyServerName;Initial Catalog=MyCatalogName;UID='XXX';PWD='YYY'"
myConn.Open

set myCmd =  new ADODB.Command (myConn)
myCmd.SQL = "Update MyTable Set MyColumn = '" & MyDataVariable & "' Where MyPK = '" & MyPKVariable & "'"
myCmd.Execute

myCmd.close
myConn.close

这篇关于MS Access中的多线程,异步处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆