2 Replies - 724 Views - Last Post: 25 July 2012 - 07:15 AM

#1 miquelx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 25-July 12

How do I solve this problem without a continuous loop?

Posted 25 July 2012 - 05:17 AM

Hello everyone,
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.

Is This A Good Question/Topic? 0
  • +

Replies To: How do I solve this problem without a continuous loop?

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6048
  • View blog
  • Posts: 23,473
  • Joined: 23-August 08

Re: How do I solve this problem without a continuous loop?

Posted 25 July 2012 - 06:14 AM

This is not C# specific but rather an architectural/design issue, so I'll move this to Software Development.
Was This Post Helpful? 0
  • +
  • -

#3 miquelx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 25-July 12

Re: How do I solve this problem without a continuous loop?

Posted 25 July 2012 - 07:15 AM

Sorry about that :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1