I use C#'s BackgroundWorker object frequently to start a thread and perform a task. What's the easiest way to accomplish the same thing in Delphi?
Here's some code in C#:
private void button1_Click(object sender, EventArgs e)
{
BackgroundWorker bg = new BackgroundWorker();
bg.DoWork += new DoWorkEventHandler(bg_DoWork);
bg.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bg_RunWorkerCompleted);
test_number++;
object[] arguments = { "test", test_number };
bg.RunWorkerAsync(arguments);
}
void bg_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
// done.
}
void bg_DoWork(object sender, DoWorkEventArgs e)
{
// do actual work here
}
A standard conforming C implementation consists of a compiler that translates compilation units as mandated by the standard, an implementation of the standard library for all functions required by the standard and something (normally a linker) that puts everything together to build an executable file.
It was based on CPL (Combined Programming Language), which had been first condensed into the B programming language—a stripped-down computer programming language—created in 1969–70 by Ken Thompson, an American computer scientist and a colleague of Ritchie.
Look into OmniThreadLibrary by Primoz Gabrijelcic, or into AsyncCalls by Andreas Hausladen, which should both give you similar functionality.
for your solution this is: delphi-components/backgroundworker this component like c# backgroundworker's event, property etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With