![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 8 of 8 total |
![]() |
Thu, Aug 16 2018 7:49 PM | Permanent Link |
Ian Branch | Hi Guys,
I'm converting an old component library from Utilmind from D2007 to D10.2.3. Going OK but stuck at the following piece of code.. {code} constructor TdcEventThread.Create(aOwner: TdcCustomThread); begin inherited Create; Owner := aOwner; AddThread; FSuspended := True; // always suspended after creation FHandle := BeginThread(nil, 0, @ThreadProc, Pointer(Self), CREATE_SUSPENDED, FThreadID); end; {code} I get the following message for the FHandle := line... "[dcc32 Error] dcThread.pas(317): E2033 Types of actual and formal var parameters must be identical" Threading has never been my thing and I can't tell which element is incorrect. @ThreadProc returns a System.Integer, Pointer(Self) rewturns a System.Pointer, CREATE_SUSPENED returns a Constant, FThreadID a System.Cardinal. Any thoughts/suggestions appreciated. Regards, Ian |
Fri, Aug 17 2018 2:39 AM | Permanent Link |
Roy Lambert NLH Associates ![]() | Ian
I assume its the same in D2006 & D2007 so D2006 (from OLH) BeginThread(SecurityAttributes: Pointer; StackSize: Cardinal; ThreadFunc: TThreadFunc; Parameter: Pointer; CreationFlags: Cardinal; var ThreadId: Cardinal): Integer; XE (from embarcadro on-line manual) BeginThread(SecurityAttributes: Pointer; StackSize: LongWord; ThreadFunc: TThreadFunc; Parameter: Pointer; CreationFlags: LongWord; var ThreadId: TThreadID): THandle; Your's BeginThread(nil, 0, ThreadProc, Pointer(Self), CREATE_SUSPENDED, FThreadID); So SecurityAttributes - looks OK StackSize - looks OK ThreadFunc - looks OK Parameter - looks OK CreationFlags - should be OK since you're using a predefined constant ThreadId - this looks like the one, even if type TThreadID = Cardinal; Its entirely its possible I'm wrong though Roy Lambert |
Fri, Aug 17 2018 3:53 AM | Permanent Link |
Ian Branch | Hi Roy,
Thanks for looking. FThreadID is defined in TdcEventThread.. {code} { TdcEventThread } TdcEventThread = class private FHandle: THandle; <<< System.Cardinal FThreadID: THandle; FTerminated: Boolean; .... .... {code} Then used for a public property ThreadID.. {code} property ThreadID: THandle read FThreadID; {code} for TdcEventThread. Hmmmm. Ian |
Fri, Aug 17 2018 3:58 AM | Permanent Link |
Matthew Jones | Ian Branch wrote:
> Types of actual and formal var parameters must be identical" My first thought matched Roy - it is the FThreadID because that's the only var there. But if that is right, then it is in the definition of your ThreadProc, as that presumably has a var in it? -- Matthew Jones |
Fri, Aug 17 2018 5:21 AM | Permanent Link |
Ian Branch | Hi Matthew,
{code} function ThreadProc(Thread: TdcEventThread): Integer; var FreeThread: Boolean; begin if Thread.FTerminated then // never executed but terminated begin FreeThread := Thread.FFreeOnTerminate; Result := Thread.FReturnValue; if FreeThread then Thread.Free; EndThread(Result); end else begin Thread.FRunning := True; try Thread.Execute; finally FreeThread := Thread.FFreeOnTerminate; Result := Thread.FReturnValue; try Thread.DoTerminate; finally Thread.FRunning := False; if FreeThread then Thread.Free; EndThread(Result); end; end; end; end; {code} |
Fri, Aug 17 2018 6:15 AM | Permanent Link |
Matthew Jones | It's just the prototype that is needed - and that of BeginThread. What is the definition of that in parameter 3?
(Sorry to be lazy, I don't have a VM with such recent Delphi running at the moment) -- Matthew Jones |
Sat, Aug 18 2018 2:52 AM | Permanent Link |
Roy Lambert NLH Associates ![]() | Ian
The only thing I can think of to try and identify the problem is to change each parameter in turn to a constant (eg ThreadProc to nil and Pointer(Self) to 0) and see if it compiles. When it does you've found the guilty party and, hopefully, can continue. Roy Lambert |
Sat, Aug 18 2018 4:19 AM | Permanent Link |
Ian Branch | Hi Roy, Matthew,
I think it boils down to FThreadID. In all others cases from a google search I see the variable used in BeginThread it is a LongWord. THandle is an Integer. So, I put a var at the start of the constructor..var x: LongWord;, added x := FThreadID; in the code and substituted x for FThreadID in the BeginThread function. It builds. ![]() to D10.2.3. Thanks for the assist guys. Regards, Ian |
This web page was last updated on Sunday, July 13, 2025 at 06:52 AM | Privacy Policy![]() © 2025 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |