RaelB
-
Content Count
72 -
Joined
-
Last visited
Posts posted by RaelB
-
-
Hi,
Are there any well known sites to post Delphi job opportunities?
Thanks
-
@Der schöne Günther: If I set a timeout the problem does not occur. Thanks a lot for your help. Kudos for noticing the thread ID issue. It is something that can be reproduced quite easily as in my test application.
-
@Der schöne Günther: Yes, it is a thread ID.
What you say is an interesting observation. I have created a small demo (attached). I am not able to reproduce the problem of Task 1 running twice, however on some occassion, the WaitForAll and Run Task 1 calls have the same Thread ID.
Here is an example trace. The issue occurred for the first run, but not the others.
0x3374 19:33:20:910 AddVideo 0x6518 19:33:21:125 WaitForAll 0x6518 19:33:21:179 Run Task 1 0x6518 19:33:22:590 --- 0x3374 19:33:24:230 AddVideo 0x47C4 19:33:24:240 WaitForAll 0x1984 19:33:24:240 Run Task 1 0x47C4 19:33:24:875 --- 0x3374 19:33:26:397 AddVideo 0x6130 19:33:26:459 WaitForAll 0x6518 19:33:26:459 Run Task 1 0x6130 19:33:27:247 ---
Perhaps if you look at the code you will see something wrong.
I am using the open source TraceTool for the logging. (https://github.com/capslock66/Tracetool)
(btw, I'm using Rio 10.3.2)
Thanks
-
Thanks alot for the suggestions, especially Der schöne Günther - It is indeed related to a TTask not completing. Since the nature of the problem relates more to TTask I am going to follow up the issue over here: https://en.delphipraxis.net/topic/4174-ttask-running-twice/
-
I have the following code. It creates 3 tasks and then calls `TTask.WaitForAll(tasks)` :
procedure TVideoFrame.AddVideo(....); var ... begin MainTrace.SendStack('AddVideo'); btnPaste.Enabled := False; btnUpdate.Enabled := False; Application.ProcessMessages; ... TTask.Run(procedure() var tasks: array of ITask; ... S: String; Res: Integer; begin Setlength(tasks ,3); MemStream := nil; tasks[0] := TTask.Create (procedure () begin ... end); tasks[0].Start; tasks[1] := TTask.Create (procedure () begin MainTrace.Send('Run Task 1'); S := GetHtml(Url); end); tasks[1].Start; tasks[2] := TTask.Create (procedure () begin ... end); tasks[2].Start; MainTrace.Send('WaitForAll'); TTask.WaitForAll(tasks); EnterCriticalSection(_CritSec); // Don't think it's necessary but just to be safe... try try .... // Process results.. except On E: Exception do MainTrace.Send(E.ClassName, E.Message); end; finally LeaveCriticalSection(_CritSec); end; TThread.Synchronize(nil, procedure() begin btnUpdate.Enabled := True; btnPaste.Enabled := True; .... end); end); end;
A normal trace would look like this:
It seems a little strange that the trace of `WaitForAll` happens before `Run Task 1`, but maybe that's because it takes a few moments before Task 1 starts to run. Anyway that is not the main issue.
The problem is I get a trace like this:
Task 1 is running twice, and you can see from the trace in a different thread. I also have a breakpoint in the `GetHtml` method, and I see that in fact it is being called twice. How does this happen? In the main user interface I only click the button once. (as you can see from the code, I disable the button so I can't click it twice anyway..)
Thanks
Rael
-
-
I have a VCL app, running on Windows 10, Delphi 10.3.2.
Sometimes when I press the X button on the main form (to exit the app), the application does not close. The Main window disappears, however the IDE continues in "Running mode" / Debug Mode, i.e. the Program Reset button continues to be Red. When I press the Red button, the program then terminates completely and normally. Not too much going on in the application. What could be causing the program execution to hang in this way? How can I go about trying to figure out the cause? (I have no OnClose or OnCloseQuery handlers)
Thanks
Rael
-
@Uwe and @emailx45, thanks for the tips. I did manage to come right eventually.
There were some errant bpl's in C:\Users\Public\Documents\Embarcadero\Studio\20.0\Bpl. Once they were deleted, things started making more sense. Not sure why they were affecting Tokyo installation though.
I uninstalled and re-installed a number of components, and also looked through the registry and found a couple of strange entries where some components where referencing a mix of Tokyo and Rio bpl's. (I did a search for rtl260) Not sure how that happened. Maybe due to a custom util that I use 🙂
-
I had installed a number of components into Delphi 10.2 (Tokyo). One such being Graphics32 which has 2 packages: GR32_R, GR32_D (in Folder Source\Packages\RX2). I subsequently installed the packages from Folder RX3 into Delphi 10.3 Rio. I did a similar thing for a few other components. Then when I tried to open 10.2 again, I got a "runtime error 236", and after pressing "OK", (well it's not really OK, but they don't give me any other choice, do they?) the IDE quits/crashes. Anyway, so I uninstalled some of the other components from 10.2 that I had also installed into 10.3 or simply deleted the bpl files from the output directory, and eventually the IDE now loads without a problem. So now I am trying to install Graphics32 into 10.2 again. Beforehand I have deleted all related bpl/dcp files from the computer (using "everything" (voidtools.com) to locate them). The GR32_R package compiles without problem. Then I try to install GR32_D, and I get this error:
Quotecompiled with : Delphi 10.2 Tokyo
madExcept version : 5.1.0
callstack crc : $bbb2a095, $d90e1a6f, $9a4b8b87
exception number : 5
exception class : EAccessViolation
exception message : Access violation at address 40828841 in module 'rtl260.bpl'. Read of address 00000010.thread $1f14:
40828841 +02d rtl260.bpl GETMEM 1964 +21 System.SysGetMem
4082a248 +004 rtl260.bpl System 4791 +20 @GetMem
4082f7d2 +00a rtl260.bpl System 17386 +1 TObject.NewInstance
4083000b +007 rtl260.bpl System 18765 +5 @ClassCreate
4082f8b7 +007 rtl260.bpl System 17445 +0 TObject.Create
4372d38d +015 GR32_RRX2.bpl Gr32_system initialization
50061276 +042 rtl250.bpl System 22836 +21 InitUnits
500612e6 +046 rtl250.bpl System 22864 +8 @PackageLoad
4368a9b1 +005 GR32_DRX2.bpl Gr32_d @PackageLoad
500a037b +03b rtl250.bpl System.SysUtils 25779 +4 InitializePackage
5985a657 +01b madExcept_.bpl madExcept InterceptInitializePackage
500a04d5 +085 rtl250.bpl System.SysUtils 25830 +18 LoadPackage
204e9b7c +008 coreide250.bpl PakLoad 146 +0 TPackage.DoLoadPackage
204e9cf1 +055 coreide250.bpl PakLoad 220 +7 TPackage.Load
204ec50d +061 coreide250.bpl PakMgr 591 +2 TDesignPackage.Load
21e1b2cb +05b delphicoreide250.bpl PasCppPakMgr 2292 +4 TIDEDesignPackage.Load
50060039 +01d rtl250.bpl System 18304 +2 @AfterConstruction
21e1b0df +06b delphicoreide250.bpl PasCppPakMgr 2217 +11 TIDEDesignPackage.DelayLoad
21f0cf80 +030 delphicoreide250.bpl PakList 939 +3 TPackageListItem.LoadWait
21f0cee7 +06f delphicoreide250.bpl PakList 914 +15 TPackageListItem.SetIsInstalled.@label
21f0bf0f +067 delphicoreide250.bpl PakList 582 +7 TPackageListItem.SetIsInstalled
21f0bcdb +0d3 delphicoreide250.bpl PakList 497 +13 TPackageList.AddPackage
21f21a2a +09e delphicoreide250.bpl BasePasProjOpts 1795 +9 TProjOptsManager.InstallPackage
21f22c9f +003 delphicoreide250.bpl BasePasProjOpts 2424 +0 TProjectOptions.InstallPackage
21eec540 +19c delphicoreide250.bpl PasMgr 13008 +18 TPascalPackageCodeUpdater.InstallPackage
21e26059 +071 delphicoreide250.bpl PkgContainers 178 +8 TStdPackageProjectContainer.CommandHandler
2050bf6b +19f coreide250.bpl ContainerIntf 862 +26 TIDEProjectManagerMenuObject.Execute
2050db8e +176 coreide250.bpl ContainerIntf 1110 +18 TProjectManagerMenuItem.Click
50c16d18 +018 vcl250.bpl Vcl.Menus 3482 +5 TMenu.DispatchCommand
50c17faa +082 vcl250.bpl Vcl.Menus 4655 +4 TPopupList.WndProc
50c17ef9 +01d vcl250.bpl Vcl.Menus 4630 +2 TPopupList.MainWndProc
5016ebce +01e rtl250.bpl System.Classes 17408 +11 StdWndProc
768e41db +00b user32.dll DispatchMessageW
50c31e1f +0f3 vcl250.bpl Vcl.Forms 10641 +23 TApplication.ProcessMessage
50c31e62 +00a vcl250.bpl Vcl.Forms 10671 +1 TApplication.HandleMessage
50c32195 +0c9 vcl250.bpl Vcl.Forms 10809 +26 TApplication.Run
0050bab2 +06a bds.exe bds 214 +7 initialization
74906357 +017 KERNEL32.DLL BaseThreadInitThunkAs far as I know Delphi 10.2 is vcl250/rtl250, and 10.3 is rtl260, so what does it mean that the call stack is showing both rtl250 and rtl260?
-
There is an enhanced version of Toolbar 2000 called SpTBXLib. see https://github.com/SilverpointDev/sptbxlib
It is actually quite a good option, since it supports VCL Styles, and is High DPI aware. It has been used in PyScripter (https://github.com/pyscripter/pyscripter ) And the author has worked on adding these features (i.e. to be High DPI aware), so I recommend that you check it out.
Dev Express has it's own skin system that does not work with the VCL styles. So if your app is using a whole range of components, it is probably a good idea not to use their Toolbar/Ribbon system. Only use individual controls you may need, and you can manually select specific styles that would match VCL Styles, if neccessary.
I would suggest for you to first upgrade your project to recent version of Delphi, using SpTBXLib and support high DPI, since that is a fair amount of work in itself. Once your app is up and running, then you could decide on replacing various components if necessary.
-
I see, thanks
-
Hi,
I see if a class has the [TestFixture] attribute, then it will be included in the Test Suite. So it seems that the
initialization
TDUnitX.RegisterTestFixture(TMyTests);is not neccessary. Maybe it just a relic from the past, or does it still serve a purpose?
-
Thanks for your help.
-
I'm using the latest version of superobject from here https://github.com/hgourvest/superobject.
It fails to parse attached json file (return nil object). I have no problem using x-superobject, and notepad++ has no problem parsing it.
Sample code:
var O: ISuperObject; S: string; StrList: TStringList; begin StrList := TStringList.Create; try StrList.LoadFromFile(....'sample.json'); S := StrList.Text; O := SO(S); if O = nil then Memo1.Lines.Text := 'O = nil' else Memo1.Text := O.AsJSon(True); finally StrList.Free; end;
Can anyone tell me why it fails?
Is there a more recent version of superobject to use? hgourvest repo is no longer maintained. (My project is using superobject, so I don't want to swap to another library..)
Thanks
-
In Data structures & Algorithm courses, there is usually a discussion on Binary Search Trees and it is seems to be an important data structure. Although in Delphi land I don't see much mention of BST. So I'm curious do people use BST and if so in what cases? or does TStringList mostly replace the need for it.
If you do use it, what implementation do you use. Most of the libraries I found don't seem to have a BST, although I did find one in https://github.com/Zeus64/alcinoe
-
It is unchecked.
I did find the problem. There was no call to RegisterTest in initialization section of test unit.
-
-
Thanks, got it.
-
Thanks, that is quite amazing. You're saying the loop is actually pausing/resuming depending on queue activity.
-
In the SimplePipeline project (from HL-III presentation), if I add a call to sleep in AddOne stage, the program (i.e. UI) blocks for 5 seconds.
procedure AddOne(const input, output: IOmniBlockingCollection); var v: TOmniValue; begin for v in input do begin output.Add(v.AsInteger + 1); Sleep(1000); end; end;
I would expect this to not block the UI, since it is running in a Thread/Task?
-
Hello,
I am looking at the code from WebSpider demo from HL-III presentation. (The project is just called pipeline)
It has code like this:
procedure TfrmWebSpider.UniqueFilter(const input, output: IOmniBlockingCollection); var uniqueUrls: TStringList; url : string; begin uniqueUrls := TStringList.Create; try uniqueUrls.Sorted := true; for url in input do begin if uniqueUrls.IndexOf(url) < 0 then begin uniqueUrls.Add(url); output.TryAdd(url); end else if FURLCount.Decrement = 0 then FSpider.Input.CompleteAdding; end; finally FreeAndNil(uniqueUrls); end; end;
When I run the demo, I see that the uniqueUrls TStringList is working on all inputs received. This is what we want, but how does this work?, since it is a local variable one would expect/imagine that it goes out of scope each time UniqueFilter is "called".
Thanks
Rael
How to tell what code is locking a file resource within an application
in RTL and Delphi Object Pascal
Posted
Hi,
When trying to modify or overwrite an existing file, I get this error:
Similarly the file cannot be deleted with SysUtils.DeleteFile. It seems that the file is actually in use within the same application (since if I close the app and restart it the file can be deleted...)
Is there any way i.e. via code or perhaps an external tool, I can find out which piece of code is locking/holding the file? Similar to how when there is a memory leak, FastMM can give a report of which code block created the object.
Thanks