-
Content Count
247 -
Joined
-
Last visited
-
Days Won
11
Primož Gabrijelčič last won the day on March 6 2023
Primož Gabrijelčič had the most liked content!
Community Reputation
223 ExcellentTechnical Information
-
Delphi-Version
Delphi 10.2 Tokyo
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
Short answer: Use Parallel.For. Long answer: Parallel.ForEach was written not for parallel processing of integers but for parallel processing of any weird kind of data. Because of that it is overly complex and not good for simple (for i in range) cases. It is usually about 10x slower than PPL's TParallel.For. That is why I later wrote Parallel.For, which works only on integer ranges and is on par with the PPL implementation.
-
ForEach runs only one "thread" at time
Primož Gabrijelčič replied to Tommi Prami's topic in OmniThreadLibrary
Use it's .OnStop function (async) or .OnStopInvoke (synchronized to the owner thread). -
ForEach runs only one "thread" at time
Primož Gabrijelčič replied to Tommi Prami's topic in OmniThreadLibrary
ExecuteAndWait processes messages in the worker thread. You have to process messages in the thread that owns the parallel task (in this case the main thread). -
ForEach runs only one "thread" at time
Primož Gabrijelčič replied to Tommi Prami's topic in OmniThreadLibrary
Although, hmmmm, I would expect Parallel.ForEach to work in blocking mode without any message processing. I will look into that as soon as possible. -
ForEach runs only one "thread" at time
Primož Gabrijelčič replied to Tommi Prami's topic in OmniThreadLibrary
Messages are still not processed while parallel for is executing. Run Parallel.ForEach.NoWait.Execute. Process messages while ForEach is running. -
ForEach runs only one "thread" at time
Primož Gabrijelčič replied to Tommi Prami's topic in OmniThreadLibrary
See: OmniThreadLibrary and console -
Calling Async from a thread causes an exception
Primož Gabrijelčič replied to andrey.b's topic in OmniThreadLibrary
Yes, it fails because the owner (anonymous thread) is destroyed before the worker (Parallel.Async). You could also run into problems because the owner thread is not processing Windows messages, which is a requirement for threads that own OTL tasks. Not in this simple example, but as soon as you start sending messages towards the owner or using OnTerminate handlers you would run into trouble.- 6 replies
-
- async
- createanonymousthread
-
(and 2 more)
Tagged with:
-
Calling Async from a thread causes an exception
Primož Gabrijelčič replied to andrey.b's topic in OmniThreadLibrary
For starters - why are you running Async from a background thread and not from the main thread?- 6 replies
-
- async
- createanonymousthread
-
(and 2 more)
Tagged with:
-
Looking forward to Delphi 12 Athens support
Primož Gabrijelčič replied to RCrandall's topic in OmniThreadLibrary
Official Delphi 12-supporting release: https://github.com/gabr42/OmniThreadLibrary/releases/tag/release-3.07.10 It should also appear in GetIt in a day or two. -
Looking forward to Delphi 12 Athens support
Primož Gabrijelčič replied to RCrandall's topic in OmniThreadLibrary
Although not officially released, OTL supports Delphi 12. Just download the latest version from the github and you're good to go. Official release will follow in two weeks. Primož -
Parallel.Pipeline & CreateProcess question
Primož Gabrijelčič replied to pushkin4219's topic in OmniThreadLibrary
I don't know. Show us the code. -
Use fController := CreateTask(TWorker.Create()).MsgWait.Run; Note the extra (). I don't know why, but compiler requires them.
-
Record as result for BackgroundWorker
Primož Gabrijelčič replied to chkaufmann's topic in OmniThreadLibrary
This should work just fine, I wrote a very similar code today and there were no problems: FWorker := Parallel.BackgroundWorker.NumTasks(1) .Execute( procedure (const workItem: IOmniWorkItem) var result: TTextBoxDetectorResults; begin var data := workItem.Data.ToRecord<TTextBoxDetectorData>; result := FAnalyzer_Asy.Analyze(data); workItem.Result := TOmniValue.FromRecord<TTextBoxDetectorResults>(result); end) .OnRequestDone_Asy( procedure (const Sender: IOmniBackgroundWorker; const workItem: IOmniWorkItem) begin var results := workItem.Result.ToRecord<TTextBoxDetectorResults>; OnAnalyzed_Asy(Self, workItem.UniqueID, results); end) You will have to put together a reproducible test case. -
Async/Await with updating visual controls
Primož Gabrijelčič replied to omnibrain's topic in OmniThreadLibrary
Yes, like that, but use TThread.Queue. There's no need to block the worker thread while memo is being updated. -
Hands-On Design Patterns with Delphi
Primož Gabrijelčič replied to Primož Gabrijelčič's topic in Tips / Blogs / Tutorials / Videos
The same goes for Packt. They sell books for $5 (action!) without asking. They even created a monstrosity which combines both my books together and they are selling it separately (again, without asking). But they did manage to make me more money than my self-published OmniThreadLibrary book, even though their commision is much higher than LeanPubs. So they do sell many books.