Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Can't use TComponent in thread object?

Posted on 2006-11-22
4
Medium Priority
?
329 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 500 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

604 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