Thread priority over Main program

Just starting out? Need help? Post your questions and find answers here.
msteffes
New User
New User
Posts: 6
Joined: Thu Oct 27, 2022 4:35 pm

Thread priority over Main program

Post by msteffes »

Hello All,
I am new to working with threads and need to understand better how priority settings affect other tasks.
My project barrows the example code in the help file section for < CreateSemaphore()> It is Producer/consumer code . I have attempted using this approach in an RS485 sniffer program for a proprietary messaging protocol. I have a thread created that will gather serial data and stuff it in to a shared List. The main program then processes the data in to meaningful messages, writes them to a file and strips the processed data of the top of the list. The problem I have run into is the Data processing in the main seems to go through the data faster than the serial thread can populate the List object. I found this very surprising as the data processing portion is a bit complex, at least to me. The serial data is streaming at about 100millisecond message interval. This is about half the speed I anticipate once I get beyond the simulation stage I have tried a very high ThreadPriority() to the Producer but the main still out runs the producer thread. Do I need to put the Data processing in to a separate thread as well, taking it out of the main line code?
infratec
Always Here
Always Here
Posts: 7582
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Thread priority over Main program

Post by infratec »

You need to tell the main loop when threre is data to process.
Look at PostEvent() with custom events.
Post Reply