I'm developing a project where I have a managing application with two tcplisteners, and i have 2 types of clients connecting to this application. The purpose is that the type1 client sends a task to the server application and then that application sends the message to the type2 client so it executes the task sent by type1 client, this message is only sent if there are type2 clients available (not executing a task already), otherwise they stay in queue.
I've thought of using a queue to achieve this, but the problem is, some tasks can't be started without the previous task being completed, also, the tasks have different priority levels.
Maybe I'm not being clear, what i mean is the following:
task1 is sent with priority level 2.
task2 is sent with priority level 2 and depends on task1 to be complete.
task3 is sent with priority level 1.
Imagining the task1 is still being executed on client1 and there is a client available to process tasks, how would I code it so the central application starts the task3 keeping the task2 in queue?
I could keep an infinite loop reading all records from the task queue but obviously that would burn all the computer resources.
Also there is the possibility for the task queue to have periods without any records.
These tasks require heavy processing so they will take some minutes to complete.
2 Replies - 897 Views - Last Post: 25 July 2012 - 07:15 AM
Replies To: How do I solve this problem without a continuous loop?
Page 1 of 1