procedure ExecCount.Execute ;
begin
intI:=0;
CoInitialize(nil);
FreeOnTerminate :=True;//线程终止时自动删除对象
StoreCount.Parameters.ParamByName('@byvStartDate').Value:=formatdatetime('yyyy-mm-dd',BeginDate);
StoreCount.Parameters.ParamByName('@byvEndDate').Value:=formatdatetime('yyyy-mm-dd',EndDate);
StoreCount.Parameters.ParamByName('@byvDept').Value:='';
StoreCount.Parameters.ParamByName('@byvPerson_Number').Value:=Person;
StoreCount.ExecProc;
intI:=1;
CountFrm.Close;
end;//上面线程执行部份 while not qryFind.Eof do
begin
Date1:=BeginDate.Date;
Date2:=EndDate.Date;
Dept1:='';
Person1:=qryFind.fieldbyname('工号').asstring;
ExecStore.Create(ManageData,Date1,Date2,Dept1,Person1); //调用线程
Gauge1.Progress:=Gauge1.Progress+1;
qryFind.Next;
end;但会报错, 异步执行时操作不能被执行?大家说下怎么改下呢,请多提提建议吧
begin
intI:=0;
CoInitialize(nil);
FreeOnTerminate :=True;//线程终止时自动删除对象
StoreCount.Parameters.ParamByName('@byvStartDate').Value:=formatdatetime('yyyy-mm-dd',BeginDate);
StoreCount.Parameters.ParamByName('@byvEndDate').Value:=formatdatetime('yyyy-mm-dd',EndDate);
StoreCount.Parameters.ParamByName('@byvDept').Value:='';
StoreCount.Parameters.ParamByName('@byvPerson_Number').Value:=Person;
StoreCount.ExecProc;
intI:=1;
CountFrm.Close;
end;//上面线程执行部份 while not qryFind.Eof do
begin
Date1:=BeginDate.Date;
Date2:=EndDate.Date;
Dept1:='';
Person1:=qryFind.fieldbyname('工号').asstring;
ExecStore.Create(ManageData,Date1,Date2,Dept1,Person1); //调用线程
Gauge1.Progress:=Gauge1.Progress+1;
qryFind.Next;
end;但会报错, 异步执行时操作不能被执行?大家说下怎么改下呢,请多提提建议吧
解决方案 »
- 如何用fast report做本页合计 值为前几页的小计的和 啊 帮忙啊
- 被TNT Unicode Control整得无奈的人又来求助了,TWideStrings(TTntStrings)的Text不干活了……
- Rave报表问题!
- 急:如何在Delphi程序中调用Windows 的命令行程序并返回结果?
- 禁用网卡(本地连接)源码公布
- 高分求救,急急急急急急急急!!!!!!
- 菜鸟问题
- 如何在按下键盘上某个键后当前窗体自动隐藏,再次按下时则弹出窗体到最前面?
- select的小问题
- Delphi数据库软件的安装程序需要配置哪些文件?为什么我的数据库安装程序不能用,望赐教
- 提交这个页面的表单 http://www.mirdy.cn/add.asp?action=sfadd
- 在字符串里提取子串的问题
Use
SyncObjs;在执行线程时
用临界区来控制线程同步
EnterCriticalSection()LeaveCriticalSection()
procedure ExecCount.Execute ;
var
InterlockedCrit : TRTLCriticalSection;
begin
intI:=0;
CoInitialize(nil);
FreeOnTerminate :=True;//线程终止时自动删除对象
EnterCriticalSection(InterlockedCrit); //进入临界区
StoreCount.Parameters.ParamByName('@byvStartDate').Value:=formatdatetime('yyyy-mm-dd',BeginDate);
StoreCount.Parameters.ParamByName('@byvEndDate').Value:=formatdatetime('yyyy-mm-dd',EndDate);
StoreCount.Parameters.ParamByName('@byvDept').Value:='';
StoreCount.Parameters.ParamByName('@byvPerson_Number').Value:=Person;
StoreCount.ExecProc;
LeaveCriticalSection(InterlockedCrit); //离开临界区
intI:=1;
end; 但是会报错啊,‘Access violation at address 7C938FEA in module 'ntdll.dll' Write of address 00000010'
在网上一找'7C938FEA'都是一些乱七八糟的答案,说什么用优化大师优化一下就可解决。
有哪位朋友也曾遇到过呢?
CoInitialize(nil);
//**FreeOnTerminate := True; //这一句放到线程的构造器中
with TADOStoredProc.Create(nil) do
try
Connection := YourADOConnection;
Parameters.ParamByName('@byvStartDate').Value := formatdatetime('yyyy-mm-dd', BeginDate);
Parameters.ParamByName('@byvEndDate').Value := formatdatetime('yyyy-mm-dd', EndDate);
Parameters.ParamByName('@byvDept').Value := '';
Parameters.ParamByName('@byvPerson_Number').Value := Person;
ExecProc;
finally
CoUninitialize();
Free;
end;
intI := 1;
CountFrm.Close;