Note that there are some explanatory texts on larger screens.

plurals
  1. POBeginThread Structure - Delphi
    primarykey
    data
    text
    <p>I've got a almost completed app now and the next feature I want to implement is threading. I chose to go with BeginThread(), although am aware of TThread in delphi. The problem I'm coming across is the structure of BeginThread() call. Normally the line in the program that would call the function I want to be threaded is</p> <pre><code>CompareFiles(form1.Edit3.Text,Form1.Edit4.Text,Form1.StringGrid2,op); </code></pre> <p>op is a integer. </p> <p>The line I've switched it out for to create a thread from it is </p> <pre><code>BeginThread(nil,0,CompareFiles,Addr('form1.Edit3.Text,Form1.Edit4.Text,Form1.StringGrid2,op'),0,x); </code></pre> <p>From the little amount of infromation I can find on how to actually use BeginThread() this should be a fine call, however on compling all I get is complier errors regarding the structure of my BeginThread() statement paramenters. </p> <p>EDIT FOR INFORMATION. </p> <p>The current procedure that calls CompareFiles is </p> <pre><code>procedure TForm1.Panel29Click(Sender: TObject); var op,x : integer; begin if (Form1.Edit3.Text &lt;&gt; '') AND (Form1.Edit4.Text &lt;&gt; '') then begin op := 3; if RadioButton7.Checked = True then op := 0; if RadioButton3.Checked = True then op := 1; if RadioButton4.Checked = True then op := 2; if RadioButton5.Checked = True then op := 3; if RadioButton6.Checked = True then op := 4; CompareFiles(form1.Edit3.Text,Form1.Edit4.Text,Form1.StringGrid2,op); end; end; </code></pre> <p>If I was to use TThread as suggested by a couple of people, and as displayed by Rob below, I'm confused at how a) I would pass op,Edit3/4.Text and StringGrid2 to the CompareFiles. Guessing from the example of TThread I've seen I thought I would replace the code above with <code>TCompareFilesThread.Execute</code>and the put the current code from Panel29Click into <code>TCompareFilesThread.Create</code> and then add</p> <pre><code>FEdit3Text := Edit3Text; FEdit4Text := Edit4Text; FGrid := Grid; </code></pre> <p>to this</p> <pre><code>FEdit3Text := Form1.Edit3.Text; FEdit4Text := Form1.Edit4.Text; FGrid := Form1.StringGrid2; </code></pre> <p>But I've got this nagging feeling that is totally off the mark.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload