omnithreadlibrary

How do I design a “conveyor” of operations with OmniThreadLibrary?

[亡魂溺海] 提交于 2019-12-23 01:14:13
问题 I have a Windows Delphi application with "Start" and "Stop" menu items accessible via a notification icon. After click on "Start", I need to do the following (as I see implementation): ThreadMonitor : The first thread is waiting for the appearance of the specified file in the specified folder. ThreadParse : Once the file appears, it should be transferred to another thread (for parsing content) and continue monitoring for the next file. ThreadDB : Once all data are parsed, save them into MySQL

Getting a Delphi TTimer to work with a multi-threading app

▼魔方 西西 提交于 2019-12-22 09:57:16
问题 I have an issue with a simple TTimer that's initiated and have its OnTimer event executed in the main app thread , the code looks like this: procedure TForm1.DoSomeStuff(); begin OmniLock.Acquire; try Parallel.Pipeline.NumTasks(MaxThreads).Stage(StageProc).Run; if (MyTimer = nil) then begin MyTimer := TTimer.Create(nil); MyTimer.Interval := 60 * 1000; // timer fired every 60 seconds MyTimer.OnTimer := MyTimerEvent; MyTimer.Enabled := True; end; finally OmniLock.Release; end; // try/finally

Delphi - Threading frameworks [closed]

柔情痞子 提交于 2019-12-17 22:36:54
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I am looking for a Threading framework to use in my Delphi application. Currently I am evaluating ‘OmniThreadLibrary’ - so far it

What would the design look like for a class that implements a threaded email sending queue?

牧云@^-^@ 提交于 2019-12-12 01:24:58
问题 So my application is a taxi call dispatch system, in which an operator receives calls over the phone and assigns received calls to a driver. On the Call Details form where the call detail is entered, as soon as the Save button is clicked, the form should close, should send an email to the taxi cab driver in a background thread, and the main form is shown, where he can select the next call and assign it to another driver. The hard bit about the design is that it should be a queue, meaning an

How to block all incoming message to a form while thread is executing

纵然是瞬间 提交于 2019-12-11 18:35:02
问题 i have the current scenario, im using omnithreadlibrary for some generic background work like this: TMethod = procedure of object; TThreadExecuter = class; IPresentationAnimation = interface ['{57DB6925-5A8B-4B2B-9CDD-0D45AA645592}'] procedure IsBusy(); procedure IsAvaliable(); end; procedure TThreadExecuter.Execute(AMethod: TMethod); overload; var ATask : IOmniTaskControl; begin ATask := CreateTask( procedure(const ATask : IOmniTask) begin AMethod(); end ).OnTerminated( procedure begin ATask

Delphi TParallel not using all available cpu

て烟熏妆下的殇ゞ 提交于 2019-12-11 10:36:48
问题 We are migrating our multi-threaded application to Delphi XE7 and are testing the new TParallel.For function. We have found that it parallelizes well on laptops (Core I-5/Windows 7 with 4 cores) achieving close to consistent 100% cpu usage. When we run exactly the same code on an Intel Xeon/Windows 2008 R2 with 2x12 cores, it only achieves about 3% usage and appears to be only using 2 of the cores. The same problem is evident using the Conways Life demo sample application. We have tried using

OmniThread: How to pass a TRect in SetParameter?

荒凉一梦 提交于 2019-12-10 11:54:03
问题 In a program using the OmniThread library, how can I pass a TRect in SetParameter? Example: procedure TestParameters(const ATask: IOmniTask); begin // how can I access the TRect here? end; FTestTask := CreateTask(TestParameters, 'TestParameters') .MonitorWith(OTLMonitor) .SetParameter('FormRect', Self.ClientRect) // does not work .Run; Is there a general rule how to use different types in SetParameter? 回答1: Use TOmniValue.FromRecord<T> and TOmniValue.ToRecord<T> . procedure TestParameters

Get a function result asynchronously in Delphi using Omni Thread Library

一笑奈何 提交于 2019-12-09 13:51:17
问题 I am trying to call a function from another unit/class which would take some time in performing the task and would return a string value. I couldn't find a good reference something similar to C# async-await like simple approach in Delphi. Using Omni Thread library seems a good idea for me. A simple example will be a great start for me. Sample approach: procedure TForm1.button1Click(Sender: TObject); begin // notify before starting the task memo1.Lines.Add('calling a asynchronous function..');

Waiting for Invoke to finish when using IOmniTaskControl/TOmniWorker

不问归期 提交于 2019-12-07 14:35:55
问题 I've created an IOmniTaskControl using a TOmniWorker, so that I can periodically run chunks of code an a specific thread. So I'll be calling Invoke as needed on this IOmniTaskControl. When I do so, I will sometimes need to wait for the execution associated with that work to complete. I tried calling WaitFor(INFINITE) on the IOmniTaskControl after the Invoke, but it hangs. I debugged and could see the method on the Invoke call completed. Am I misunderstanding the use of WaitFor with

How do I design a “conveyor” of operations with OmniThreadLibrary?

雨燕双飞 提交于 2019-12-07 12:37:24
I have a Windows Delphi application with "Start" and "Stop" menu items accessible via a notification icon. After click on "Start", I need to do the following (as I see implementation): ThreadMonitor : The first thread is waiting for the appearance of the specified file in the specified folder. ThreadParse : Once the file appears, it should be transferred to another thread (for parsing content) and continue monitoring for the next file. ThreadDB : Once all data are parsed, save them into MySQL DB. (Another background thread with active DB connection?) ThreadLog : If there are any errors in the