Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6232003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:02:24+00:00 2026-05-24T10:02:24+00:00

I have a thread and a Progress Routine (a function) inside it (in my

  • 0

I have a thread and a Progress Routine (a function) inside it (in my thread class).

I try to do this inside the thread:

CopyFileEx(pchar(ListToCopy.Strings[Loop]),pchar(TN+ExtractFileName(ListToCopy.Strings[Loop])), @ProgressRoutine, nil, nil, 0);

But I get an error: “Variable required” (the error is in this: @ProgressRoutine). If to make the function ProgressRoutine outside the thread then all will be normal.

How to use that function inside thread?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:02:26+00:00Added an answer on May 24, 2026 at 10:02 am

    When you say “outside the thread” and “inside the thread”, do you mean “as a standalone function” and “as a member of the thread object”? Because if a function is a member of an object, its signature is different, so it doesn’t match what the compiler is expecting.

    The way you can resolve this is to pass Self to CopyFileEx as the lpData parameter. This gives it a pointer that it will pass back to the callback. Write your callback as a standalone function that interprets the lpData parameter as a thread object reference and uses that to call the method on your thread object with the same parameters.

    EDIT: Simple example. Let’s say that the callback only has two parameters, called “value” and “lpData”:

    procedure ProgressRoutine(value: integer; lpData: pointer); stdcall;
    var
      thread: TMyThreadClass;
    begin
      thread := lpData;
      thread.ProgressRoutine(value);
    end;
    
    procedure TMyThreadClass.ProgressRoutine(value: integer);
    begin
      //do something with the value here
    end;
    
    procedure TMyThreadClass.Execute;
    begin
      CopyFileEx(pchar(ListToCopy.Strings[Loop]),pchar(TN+ExtractFileName(ListToCopy.Strings[Loop])), @ProgressRoutine, Self, nil, 0);
      //passing Self to lpData; it will get passed back to the callback
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a thread that, when its function exits its loop (the exit is
I have a thread that needs to be executed every 10 seconds. This thread
I have a thread that appends rows to self.output and a loop that runs
I have a problem with my code. I lunch the thread and this thread
I have progress bar in every item inside my listview. When I tap an
I have progress form which delegate: // in ProgressForm thread public delegate void executeMethod(object
I have a thread which extends Thread. The code looks a little like this;
I have a background thread doing some work and a UI displaying the progress,
I have the following thread which simply prints a dot every 200ms: public class
I have thread exception handler which saves the exception stack trace and should close

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.