Questions tagged [omnithreadlibrary]
OmniThreadLibrary is a Delphi library meant to ease threading.
124
questions
0
votes
0
answers
94
views
How to use SSH connection from inside thread using omnithread library?
I use Devart TScSSHClient component to start a SSH connection to a device, after connecting I use SSHterminal to send a command and retrieve the result.
My question How can I end the thread manually (...
1
vote
1
answer
40
views
IOmniTaskControl.Unobserved - the task is never destroyed
I am trying to run a fire-and-forget task - IOmniTaskControl.Unobserved works well enough with either IOmniTaskControl.Run or IOmniTaskControl.Schedule(IOmniThreadPool), but the IOmniTaskControl ...
1
vote
1
answer
191
views
CoInitialize/CoUninitialize error handling in OTL TOmniBlockingCollection (COM multi-threading)
I am using TOmniBlockingCollection from a "Server Thread".
In this thread, I am hosting a Single-Threaded Apartment COM object to a DataProvider (CoInitialize() and CoUninitialize() are ...
1
vote
1
answer
94
views
IOmniPipeline - 2nd stage is not getting executed
I have a simple implementation of pipeline (IOmniPipeline) but the 2nd stage that is added is not being executed.
Code follows:
var
OmniPipeline: IOmniPipeline;
begin
OmniPipeline := Parallel....
2
votes
1
answer
209
views
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 ...
0
votes
0
answers
146
views
Omnithread unobserved nested thread not released when expected
Background
My Flagship App seems to leak memory. Well, not really but just during runtime. Investigating this showed the memory 'leak' is resolved when the app closes, but not in between.
I am using a ...
1
vote
1
answer
264
views
Delphi: SQL Query in Omni Parallel.foreach blocking main thread
I have a parallel.foreach loop which is blocking the interface from responding. In the loop I am calling a function which calls a mySQL stored procedure. I would like this to happen in the background ...
1
vote
1
answer
217
views
"Emergency" termination of omnithread IOmniParallelTask
Background
I have a unit test in which I check if my handler code code performs well during multi-thread stress:
procedure TestAppProgress.TestLoopedAppProgressRelease_SubThread;
begin
var bt:=...
0
votes
1
answer
284
views
Is there a way to exit a thread in a Parallel.foreach loop which is stuck
I am using OmniThread Parallel.foreach(). There are instances where the loop takes a long time or gets stuck.
I would like to know, is it possible to timeout each process in the Parallel.foreach() ...
3
votes
1
answer
204
views
Omnithread: Create a task wrapper / modify a task that adds some extra pre- and post processing to an alredy existing task
Some background:
Basically it comes down to that I want to be able to "execute" the task in the current thread.
Why? -I have a task creator routine, and one time I want the task to be executed ...
1
vote
1
answer
212
views
parallel.async, pass parameters thread-safe
Take a look at this (pseudo) code
procedure TestASync;
begin
var lSomeIntf:=TSomeImplementor.Create as ISomeIntf;
parallel.ASync(
procedure
begin
sleep(1000); // allow the main ...
-1
votes
1
answer
153
views
OmniThreadLibrary: How to run Parallel.For.Execute without using anonymous procedure?
The Execute method of Parallel.For has a TOmniIteratorDelegate parameter. But I'm unsure on how to assign a procedure to a variable of that type. The reason for doing this is that I do not want to use ...
2
votes
1
answer
371
views
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, ...
1
vote
1
answer
2k
views
Delphi OmniThreadLibrary and Async
Hopefully a simple one. I am using an OTL Parallel.For loop to process lots of data. The amount of data can change and if there is a lot (that takes over 2 seconds) Windows flickers the application ...
0
votes
0
answers
92
views
How to cancel an IOmniParallelSimpleLoop?
I'm starting using the OTL for a simple project but I'm currently stuck at stopping and restarting a simple parallel loop.
Use case
The user is able to start a query to resolve hostnames of a list ...
2
votes
0
answers
126
views
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
System.StrUtils.Containstext(...
10
votes
1
answer
913
views
Why do I need Sharemem in my Delphi dll which only exposes a function with WideString parameters?
I have a dll and a test application written in Delphi. The test application uses multiple threads to call the function exported by the dll. The exported function has a trivial thread safe ...
1
vote
1
answer
78
views
What abstraction to use for an ASynchronous data collection driver
I would like to implement a mechanism in my server application but I'm not sure which OTL abstraction would be best appropriate.
My application collects data about various types of equipements.
Some ...
0
votes
1
answer
445
views
How do I get a boolean result from a function using OmniThreadLibrary?
I have a Delphi (Windows) application created using Delphi 10 that has some blocking calls that I would like to convert to using threads. Unfortunately for me, these are not procedures, but functions....
2
votes
3
answers
1k
views
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 ...
0
votes
0
answers
109
views
How to restart the job again without freeing pipeline input
I'm using OTL, pipelines tasks to check a bunch of URLs. My question is: How to restart the search again quickly, I mean it takes time to add the strings again to Pipeline input and start again, is ...
0
votes
1
answer
172
views
How to get Worker from the IOmniTaskControl?
Is it possible to get the Worker object from a task handle of the type IOmniTaskControl? For example, on a terminate event, I want to log details of which worker was affected.
0
votes
0
answers
129
views
What OTL high level abstraction is best suited for parallel picture loading?
I would like to expose you my problem here. I'm trying to build a user interface in one of my application where the user can see multiple pictures (TImage objects) on the same form.
These pictures ...
3
votes
1
answer
789
views
Main thread blocking parallel thread?
Create a VCL Forms Application, put a TButton and a TMemo on the Form, and write this code in the button's OnClick handler:
uses
OtlParallel, OtlTaskControl;
procedure TForm2.btnStartLoopClick(...
1
vote
1
answer
824
views
How to set a higher task priority to a Parallel.Async background task?
I need to assign a higher task priority to a Parallel.Async background task. Since the OmniThreadLibrary has SetPriority: How can I set a specific priority to this Parallel.Async task?
uses
...
2
votes
1
answer
648
views
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, ...
-1
votes
1
answer
278
views
Delphi OmniThreadLibrary 3.03b: IBackgroundWorker - Termination doesn't work
I have problem with termination of BackgroundWorker in OmniThreadLibrary. Everything is OK, but when I want to terminate BackgroundWorker, termination has failed and BackgroundWorker is still alive. ...
3
votes
1
answer
308
views
Delphi - Omnithreadlibrary, death of main thread in console application
I have a problem with main thread in BackgroundWorker (high level OmniThreadLibrary component) in console application. Object in main thread (whole application) dies as soon as it schedules WorkItems ...
1
vote
1
answer
240
views
How to Stop all Pipeline tasks correctly
how to stop Pipleline tasks correctly, I've tried but when i press Abort button i get an AV, i'm not too good at debugging,i have reached to DoOnStop(task); in OtlParallel then i couldn't figure out ...
1
vote
1
answer
146
views
How to use Rcords to pass parameters to the queue
how i can pass memo lines strings to TRecords fields to use theme as a parameters for idHTTP POST methode?
usually id do it like this
for i := 0 to Memo1.Lines.Count-1 do
begin
P := Pos('+', ...
2
votes
1
answer
2k
views
How to use Pipeline pattern in Delphi
I am trying to implement a Pipeline pattern in my test project (How to make a Mutlithreded idhttp calls to do work on a StringList), but am having a struggle adapting TThread code to Pipeline pattern ...
3
votes
0
answers
299
views
How to trigger TIdHTTP.Disconnect when running in a OmniThreadLibrary task
I am wondering how I may Disconnect an instance of TIdHTTP in Delphi Seattle while it is executed in an anonymous procedure of CreateTask from the OmniThreadLibrary.
My current code looks like this:
...
2
votes
1
answer
214
views
OmniThreadLibrary C++ builder Build issues
I'v been trying to get OmniThreadLibrary to run in builder, i've built it with all the c++ required files it builds ok but when i use it in an c++ builder app i get a bunch of error messages that look ...
0
votes
1
answer
159
views
How to add tasks to OTL to be processed LIFO?
My app scans folders for images and generates thumbnails from them to draw in a grid. I have a OnDrawCell handler, which adds a task to OTL to read required image, resize it (async) and draw back on ...
0
votes
1
answer
462
views
Handling NOTICE events from PostgreSQL in a separate thread in Delphi with Devart's PgDAC components
I want to execute long queries in a separate thread in order to be able to abort them and also to give feedback to the users. All of this is working but I sometimes get Access Violations because, I ...
0
votes
1
answer
330
views
OmniThreadLibrary memory leak (consumption) on pipeline running from another thread
I'm running pipeline (thread's pipeline from OmniThreadLibrary) from another thread and got memory leak or rather memory consumption. But when application close then it's ok and there are no memory ...
1
vote
1
answer
191
views
How can I check exceptions when using IOmniTaskControl/TOmniWorker?
I'm using an IOmniTaskControl/TOmniWorker to funnel code execution onto a specific thread. I'll reuse this IOmniTaskControl repeatedly for multiple Invoke calls. How do I check for exceptions that ...
2
votes
0
answers
439
views
Paint Polygons Multithreading delphi
For quite some time I tried to improve the speed of my painting program. Unfortunately I just achieved some small improvements by using the OmnithreadLibrary and also by parallelizing the painting ...
3
votes
1
answer
630
views
Waiting for Invoke to finish when using IOmniTaskControl/TOmniWorker
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, ...
-3
votes
1
answer
267
views
How to prevent OTL Pipeline from making its input sealed?
Many years ago in the old forum I asked Primozh if Pipeline pattern can be kind of Uroboros, feeding half-complete results back to itself.
Back then Primozh said it would be straight-forward and ...
2
votes
0
answers
292
views
Memory leaks in OmniThreadLibrary's Parallel.ForEach
I use OmniThreadLibrary. It has a parallel method ForEach.
I'm working on high loaded system and I need to handle some array in parallel. But I get a memory leak.
Here is a sample:
procedure TForm7....
3
votes
1
answer
202
views
Exceptionhandling with IOmniParallelTask not working
Unhandled exceptions within IOmniParallelTask execution should (as I understand the docs) be caught by the OTL and be attached to IOmniTaskControl instance, which may be accessed by the termination ...
3
votes
1
answer
259
views
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 ...
0
votes
1
answer
318
views
parallel hough algorithm using omnithread lib
I want to speed up image processing using the hough circle detection.
// For all rows in image:
for y:=0 to AnalysisBitmap.Height-1 do
begin
// For all pixel in one row :
for x:=0 to ...
2
votes
1
answer
556
views
How can i send messages from a Background Task to MainForm (OmniThreadLibrary)
How can i send messages (TOmniMessage) from Background Task to Main Form?
I want send follow message to Mainform:
Memo1.Lines.Add(Format('BEGIN: %s', [msg.MsgData.CastToStringDef('')]));
main.pas (...
1
vote
1
answer
265
views
OTL can't be compiled under D2007
I downloaded the OTL http://www.omnithreadlibrary.com/
and compile the D2007 grouproj, install the package, without problem.
I then create a simple console application that uses OtlParallel unit, of ...
0
votes
0
answers
375
views
parallel painting into a TBitmap
the question here merge paint results in thread bitmap painting is derived from using TThread and older versions of DELPHI.
I found now the omnithread library shipped with Delphi XE 7 and can not ...
3
votes
1
answer
5k
views
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-...
1
vote
1
answer
972
views
How to pass an array as parameter to a task with SetParameter from OmniThreadLibrary?
In Delphi XE8, I am trying to pass an array to the OTL task in SetParameter from OmniThreadLibrary:
implementation
type
TCookie = record
Name: string;
Value: string;
ExpDate: ...
1
vote
0
answers
352
views
Is it safe to use local variable in OTL Async/Await Thread?
I am sorry for asking such a simple question. This is the first time I am using a background thread in VCL. So I was wondering if it is safe to use local variable in Async part?
procedure Tfrm1....