Benmik
Members-
Content Count
10 -
Joined
-
Last visited
Community Reputation
1 NeutralRecent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
Thank you so much, Primož. I had read everything but missed out on the fact that Parallel.For is blocking. Right now it goes like this: var FFor:IOmniParallelSimpleLoop; ... Timer.enabled := True; FFor := Parallel.For(0,JPGList.Count - 1) .NumTasks(Environment.Process.Affinity.Count - 1); FFor.Execute(procedure (i:integer) begin CreateThumbs(JPGList[i]); end); While not FFor.WaitFor(250) do Application.ProcessMessages; Timer.enabled := False; FFor := nil; The timer fires now OK and due to "Application.ProcessMessages" the progress is being displayed in the status bar. It's a bit slower then before, though. I'm still experimenting a little.
-
I read JPG files from disk into a TObjectList and create thumbnails from them that are painted onto a TImage. For creating thumbnails and displaying them I have been using AsyncCalls by Andreas Hausladen for a long time, but now I want to switch to OTL because AsyncCalls isn't maintained any longer. Let's say there are 800 JPG in a directory, the first 30 of which fit on the screen. So I force an update of the TImage every time one of these 30 thumbnails has been painted. After that I display a message on a TStatusBar every 50 thumbnails or every second, whichever comes first. I noticed a considerable time lag of a few seconds before the first thumbnail appeared on the screen, so I tried to use a self created thread pool which didn't help much. ThumbPool := CreateThreadPool('VSBPool'); ThumbPool.MaxExecuting := Environment.Process.Affinity.Count - 1; ThumbPool.MaxQueued := JPGList.Count - 1; Parallel.For(0,JPGList.Count - 1) .TaskConfig(Parallel.TaskConfig.ThreadPool(VSBPool)) // .TaskConfig(Parallel.TaskConfig.MonitorWith(OmEvMon)) .NumTasks(Environment.Process.Affinity.Count - 1) .Execute( procedure (i:integer) begin CreateThumbs(JPGList[i]); end); Everything works OK, except for I cannot get the status bar to display the progress. I use a global variable for the count of the produced thumbnails that is incremented (TInterlocked.Increment) in "CreateThumbs". With AsyncCall's "TAsyncCalls.VCLInvoke(procedure begin DisplayProgress end)" in "CreateThumbs" this worked like a charm. But not in OTL. What I have tried so far: 1. A simple timer firing "DisplayProgress" every 500 milliseconds. Timer apparently doesn't get to fire. 2. Using TOmniEventMonitor. Warning: 'TOmniTaskControl.SetMonitor: Task can be only monitored with a single monitor' 3. Using Parallel.Async() + "DisplayProgress". Program is slowed down to a creeping pace. What's the trick, what needs to be done? Is Parallel.For the right option here? What can I do do get rid of that time lag (singlethreaded the thumbnails appear instantaneously)?
-
What should use: Stringlist, Advanced Record, Database or Tlist Class?
Benmik replied to Johansy's topic in Algorithms, Data Structures and Class Design
Just in case the question still is open: I find it very hard to understand what exactly you are talking about. For instance, what does "introduce the user with a certain to their own." mean? Just guessing I would probably create a small class and use it in a generic TObjectList. -
Depth First Search vs. Breadth First Search in directories
Benmik replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
Is directly accessing the MFT an option? -
It was by no means meant that way. On the contrary, like everybody else I admire and cherish your capabilities as a programmer, but feel bad every time I witness you treating people badly for minor reasons. I pity this, no more and no less.
-
This would be greatly unfair towards Mahdi Safsawi who has put a lot of effort into teaching us something. I am not the one to judge if he is fully right in everything he says, but I'm grateful for all the people who contribute.
-
Yes, I certainly do. To mourn over a "noble mind" that has gone astray is certainly nothing that would make many people feel offended. (In German it's "ein großer Geist" which I like even better). If you feel this is without friendliness, respect or tact then please! go ahead and try using it yourself! I'm not a judge, I express a personal opinion. And, with due respect, I intend to continue doing so. In order to prevent me from living in a world with "judges" and "disciplining" people, if they "deserve" it. I cannot believe you actually mean what your second sentence implies.
-
Yes, another one of those sarcastic remarks that are so characteristic for you. But neither great merits as a Delphi programmer nor the sophisticated use of Oxford English entitle you to treat people the way you do, especially on stackoverflow. The slightest slip and you are cracking down on the poor devils, and I might be wrong, but in my opinion it has gotten worse in the recent years. This is still a community of human beings, after all, and they should be treated as such. Friendliness, respect, tactfulness and even a certain warmth are never wrong, even with programmatical sinners and wrongdoers.
-
I like that. Yes, it was meant as a rather bitter comment. Dear David: Oh, what a noble mind is here o'erthrown!
-
It is such fun watching you. Alas, no popcorn at hand presently.