Solved

Can't use TComponent in thread object?

Posted on 2006-11-22
4
318 Views
Last Modified: 2010-04-05
I've added a Thread Object named TProgressThread to my Delphi7 Win32 project.  I created this method in the unit:

procedure TProgressThread.GetRemoteFile;
begin
     FtpClient1 := TFtpClient.Create(Self);
...
end;

I get this error when compiling:

[Error] ProgressThread.pas(72): Incompatible types: 'TComponent' and
'TProgressThread'

Line 72 is the FtpClient1 line above.   I'm trying to put the downloading of a file on its own thread.  Why can't I use the FtpClient1 object in the thread class?

Thanks,
Brett

0
Comment
Question by:brettr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
Russell Libby earned 125 total points
ID: 18000455
No one says you can't... you just can't pass the thread as the owner. Try passing nil instead.

Regards,
Russell
0
 

Author Comment

by:brettr
ID: 18000844
That does compile but when I create the thread in another unit as

thread.Create(true);

I get this error after running the above line:

Debugger Exception Notification
Project myapp.exe raised exception class EAccessViolation with message 'Access' violation at address 00403B6A in module 'myapp.exe'.  Read of address 8BD88B4F'.  Process stopped.  Use Step or Run to continue.

Do you have any suggestions for that?

Thanks,
Brett
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 18001023
Is TFtpClient a VCL component or uses a VCL component, ie does it display anything?
The VCL is not threadsafe so it may not be usable in a thread.
0
 

Author Comment

by:brettr
ID: 18001166
I see my problem.  I should done this:


     thread := TProgressThread.Create(true);
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question