Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8138443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:29:46+00:00 2026-06-06T11:29:46+00:00

I’ve got a UI which can queue up jobs of radically different types. At

  • 0

I’ve got a UI which can queue up jobs of radically different types. At present, it does this by storing the job in the appropriate table in a database (Table-per-JobType)

My back-end process then comes along, picks up the job(s), and assuming there’s an available worker (thread), uses it to execute the appropriate method for the job.

in PseudoCode:

While(Runnning) {
    While(Queue1.HasJobs && Workers.IdleCount > 0) {
        FirstIdleWorker.Execute(Queue1Method(Type1Job));
    }

    ...

    While(QueueN.HasJobs && Workers.IdleCount > 0) {
        FirstIdleWorker.Execute(QueueNMethod(TypeNJob));
    }
    //Wait for a job to complete or a polling timeout if queues are empty
}

(It’s not actually that naive but it illustrates the order in which work is processed)

As you can see, this works but it doesn’t take into account what order jobs were added in. This isn’t a deal breaker as jobs are atomic but it is annoying from a UI perspective – eg User 1 Queues up 20 jobs of Type 2, then User 2 Queues up 1,000 jobs of Type 1. User 1 now has to wait for all User 2’s jobs to complete before their (relatively) quick jobs are processed.

Jobs do have a CreatedOn property so determining the order isn’t difficult but how best to implement a combined queue in a strongly-typed way that isn’t spaghetti code?

I’m trying to avoid a “GenericJob” object with a .CreatedOn, .Queue1Id, .Queue2Id, .Queue3Id as this just feels sloppy.

While FIFO is broadly what I’m after, it’s not a strict requirement – I just don’t want items to be bumped forever.

Is there a pattern for this sort of thing? If not, can someone point me at a good tutorial please?

(Incidentally, these are potentially long-running jobs. I’m actually using the TPL behind the scenes to manage workers once the jobs are taken from the Queue but I do still need to manage the queue myself as there are far more jobs than I could load into memory in one go)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:29:48+00:00Added an answer on June 6, 2026 at 11:29 am

    Poke me if I’m wrong, I hope this pseudo-code explains the Interface Abstraction okay.

    An interface might look like:

    enum JobTypes
    {
        JobType1 = 0x01,
        JobType2 = 0x02,
        JobType3 = 0x03
    }
    interface IJob
    {
        int ID { get; set; }
        JobTypes JobType { get; set; }
        DateTime Date { get; set; }
        bool Complete { get; set; }
        void Process(List<object> parameters);
    }
    

    Each job type processor implements this interface, change and add properties to suit your needs:

    class JobType1 : IJob
    {
        public int ID { get; set; }
        public JobTypes JobType { get; set; }
        public DateTime Date { get; set; }
        public bool Complete { get; set; }
        public void Process(List<object> parameters)
        {
            throw new NotImplementedException();
        }
    }
    

    You could then mix the job types into one list:

    List<IJob> joblist = new List<IJob>();
    

    and possibly sort them by date using lambda:

    joblist.Sort((a, b) => DateTime.Compare(a.Date, b.Date));
    

    get a list of unprocessed jobs (does not check for those busy processing*)

    List<IJob> undone = joblist.Where(job => job.Complete == false) as List<IJob>;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.