Home > Back-end >  Under Xp compile multithreaded program under Windows 7 32 bit unable to open multiple threads,
Under Xp compile multithreaded program under Windows 7 32 bit unable to open multiple threads,

Time:10-14

You ever encounter this situation, and there is no execution threads,
Below is part of the code within the thread, help me to look at which there is a problem,

 procedure thAutoMsg. Execute; 
Var
AdoC: TADOConnection;
QryMsg: TADOQuery;
The begin
FreeOnTerminate:=True;

AdoC:=TADOConnection. Create (nil);
AdoC. The ConnectionString:=Main_F. ConMain. The ConnectionString;
AdoC. LoginPrompt:=False;
AdoC. KeepConnection:=True;
AdoC.Com mandTimeout:=60;
AdoC. ConnectionTimeout:=60;
AdoC. Open;

QryMsg:=TADOQuery. Create (nil);
QryMsg. Connection:=AdoC;

While Main_F. BtnCheckOrder17uooStop. Enabled the do
The begin

CodePudding user response:

Thread doesn't perform, you showed us the execute in the east have much use ,
Under the xp normal?
Under Windows 7 is not normal to confirm whether have permissions, confirm if use the database driver, such as
You first breakpoint with a single step again say,

CodePudding user response:

Upstairs brother truth!
Only the Execute code open don't come out what!
Go tracking by oneself!
Ha ha!
If able to perform under XP!
Under Windows 7 problem is not big!
Has very little to do with the Execute code!
Ha ha!

CodePudding user response:

The
refer to the original poster haochin response:
you ever encounter such a situation, and there is no execution threads,
Below is part of the code within the thread, help me to look at which there is a problem,

 procedure thAutoMsg. Execute; 
Var
AdoC: TADOConnection;
QryMsg: TADOQuery;
The begin
FreeOnTerminate:=True;

AdoC:=TADOConnection. Create (nil);
AdoC. The ConnectionString:=Main_F. ConMain. The ConnectionString;
AdoC. LoginPrompt:=False;
AdoC. KeepConnection:=True;
AdoC.Com mandTimeout:=60;
AdoC. ConnectionTimeout:=60;
AdoC. Open;

QryMsg:=TADOQuery. Create (nil);
QryMsg. Connection:=AdoC;

While Main_F. BtnCheckOrder17uooStop. Enabled the do
The begin



,
1. The AdoC: TADOConnection; Definition to thread Private definition
The AdoC:=TADOConnection. Create (nil); On the thread inside the Create event;

2. The thread inside calling ADO database access to use CoInitialize and CoUnInitialize;
Call Coinitialization to Uses Comobj;



USES Comobj;

Procedure thAutoMsg. Execute;
Var
QryMsg: TADOQuery;
The begin
FreeOnTerminate:=True;
try
CoInitialize (nil);

AdoC. The ConnectionString:=Main_F. ConMain. The ConnectionString;
AdoC. LoginPrompt:=False;
AdoC. KeepConnection:=True;
AdoC.Com mandTimeout:=60;
AdoC. ConnectionTimeout:=60;
AdoC. Open;

QryMsg:=TADOQuery. Create (nil);
QryMsg. Connection:=AdoC;

While Main_F. BtnCheckOrder17uooStop. Enabled the do
The begin
.
end;

the finally
CoUnInitialize;
end;

end;

CodePudding user response:

 procedure thAutoMsg. Execute; 
Var
AdoC: TADOConnection;
QryMsg: TADOQuery;
The begin
FreeOnTerminate:=True;

AdoC:=TADOConnection. Create (nil);
AdoC. The ConnectionString:=Main_F. ConMain. The ConnectionString;//this sentence has a problem, use a simple String String to assignment, use. The ConnectionString property is no,
AdoC. LoginPrompt:=False;
AdoC. KeepConnection:=True;
AdoC.Com mandTimeout:=60;
AdoC. ConnectionTimeout:=60;
AdoC. Open;

QryMsg:=TADOQuery. Create (nil);
QryMsg. Connection:=AdoC;

While Main_F. BtnCheckOrder17uooStop. Enabled the do
The begin