Questions tagged [omnithreadlibrary]

OmniThreadLibrary is a Delphi library meant to ease threading.

It's written mainly by Primož Gabrijelčič and released under BSD license.

Resources:

124 questions
3
votes
1 answer

proper construction of ParallelTask (IOmniParallelTask) with cancellation & termination handler

I am just playing around with the OmniThreadLibrary after reading the docs, but I am still facing some simple/early problems on constructing a ParallelTask. After the construction of a ParallelTask with cancellationToken and terminationHandler,…
codejanovic
  • 522
  • 5
  • 9
3
votes
1 answer

Get a function result asynchronously in Delphi using Omni Thread Library

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…
3
votes
3 answers

Parallel write to array slower than serial write using OmniThreadLibrary

I am working on an implementation of the Differential Evolution optimization algorithm, and want to speed up the calculation time by calculating population members in parallel. I am using the OmniThread library, and have successfully parallelized my…
vehystrix
  • 418
  • 5
  • 9
3
votes
1 answer

Can OmniThreadLibrary be used in a Delphi Windows Service?

OmniThreadLibrary is a very interesting library. However, I'm worried about its use in a Windows Service. All tests from repository are Forms based. And most of them use (implicitly or explicitly) a message-based infrastructure (via…
JohnnyG
  • 31
  • 1
3
votes
1 answer

Error "Task can be only monitored with a single monitor" when setting my monitor to a task in dll

I use OmniThreadLibrary 2.09 in my dll, main application and dll are using the same SimpleShareMem memory manager. I created my own monitor with this code: FMonitor: TOmniEventMonitor; ... FMonitor := TOmniEventMonitor.Create(nil); When I try…
Andrew
  • 3,696
  • 3
  • 40
  • 71
3
votes
2 answers

How to pass params to Parallel.Async() in OmniThreadLibrary?

How does one pass some parameters from the main thread to the working thread (ie the following procedure)? Parallel.Async( procedure (const task: IOmniTask) begin //How does one pass in 'myParam' from the main thread, so that the statement…
Edwin Yip
  • 4,089
  • 4
  • 40
  • 86
3
votes
2 answers

How can I use more than 60 tasks in a task group?

How can I use more than 60 tasks in a Taskgroup? I can loop from 0 to N and create tasks but that will not give me any message handling. I use OTL EventMontior for sending messages from tasks.. The reason I ask is because using Indy I am limited to…
Santos Oliveira
  • 497
  • 1
  • 8
  • 18
3
votes
1 answer

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

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 …
TheDude
  • 3,045
  • 4
  • 46
  • 95
2
votes
1 answer

How to empty OmniThreadLibrary ThreadPool Queue?

I just discovered OmniThreadLibrary & started playing with it. I'm trying to launch, say, no more than 20 tasks max and send the rest of the tasks to queue. I modified the OmniThreadLibrary's 00_Beep project to do this: const TASKS_COUNT =…
TheDude
  • 3,045
  • 4
  • 46
  • 95
2
votes
1 answer

Delphi EurekaLog and OmniThreadLibrary incompatible?

I have a simple program that creates an OmniThread workerpool in the 'initialization' of a unit and destroys the same pool in the 'finalization' of that unit. This works fine as long as we do not use EurekaLog. If we include EurekaLog an access…
Laurens
  • 325
  • 2
  • 12
2
votes
1 answer

Download and process files with IOmniPipeline

My goal is a VCL app where I need to concurrently download some files (URLs stored in TDataSet), then each of downloaded file must be processed (one-by-one). During app working GUI must not be hanged, user user should be able to cancel (interrupt)…
2
votes
0 answers

Parallel.For takes longer than for loop

In Delphi Berlin 10.1, I have a for loop: for i := 0 to slSMP.Count - 1 do begin if System.StrUtils.Containstext(slSMP.ValueFromIndex[i], ThisSearchTerm) or …
user1580348
  • 5,721
  • 4
  • 43
  • 105
2
votes
1 answer

Is it possible to send messages between Tasks (OmniThreadLibrary)?

My app will have several tasks for various actions. All tasks are created in FormCreate and terminated in FormDestroy, they are always running as long as the app is running. The main thread's only purpose is to handle user I/O and send user inputs…
Holgerwa
  • 3,430
  • 9
  • 42
  • 50
2
votes
3 answers

Does Delphi Parallel.For have a MaxParallism

In C#, you can limit the number of threads, like this: Parallel.For(0, 10, new ParallelOptions { MaxDegreeOfParallelism = 4 }, count => { Console.WriteLine(count); }); Does Delphi have this in latest compiler e.g. Berlin. Or does the…
justyy
  • 5,831
  • 4
  • 40
  • 73
2
votes
1 answer

How to completely terminate Parallel task from main thread?

How can I completely terminate this background thread from the main thread, i.e. that not even the code in OnTerminated will be executed? uses CodeSiteLogging, OtlParallel, OtlTaskControl, OtlTask; procedure TForm2.btnParallelAsyncClick(Sender:…
user1580348
  • 5,721
  • 4
  • 43
  • 105
1 2
3
8 9