?
Solved

Can't use TComponent in thread object?

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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

765 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