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 9168349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:36:21+00:00 2026-06-17T15:36:21+00:00

Even though this question sounds as a duplicate, I searched a lot but couldn’t

  • 0

Even though this question sounds as a duplicate, I searched a lot but couldn’t find a proper solution.

I have following classes

public enum ChangeType
{ 
    Add,
    Modify,
    Delete
}



public enum ChangedObjectType
{ 
    Project,
    Customer,
    Border,
    Photo
}

public struct ChangeInfo
{
    public ChangeType typeofChange { get; private set; }
    public ChangedObjectType objectType { get; private set; }

    public string objectID { get; private set; }

    public ChangeInfo(ChangeType changeType, ChangedObjectType changeObj, string objectId):this()
    {
        typeofChange = changeType;
        objectType = changeObj;
        objectID = objectId;
    }

}

thread :

public class ChangeInfoUploader
{ 
    static Queue<ChangeInfo> changeInfoQueue = new Queue<ChangeInfo>();
    static Thread changeInfoUploaderThread = new Thread(new ThreadStart(ChangeInfoUploaderProc));
    static bool isStarted = false;
    static Project currentProject;

    public static void Initialize(Project curproject)
    {
        currentProject = curproject;
        isStarted = true;
        changeInfoUploaderThread.Start();
        ResumeData();
    }

    static void ChangeInfoUploaderProc()
    {
        while (isStarted)
        {
            if (currentProject != null)
            {
                ChangeInfo? addToDb = null;

             // I need to sort changeInfoQueue before dequeue
                lock (changeInfoQueue)
                {
                    if (changeInfoQueue.Count != 0)
                        addToDb = changeInfoQueue.Dequeue();
                }
            }
        }
        Logdata();
        changeInfoUploaderThread.Abort();
    }
}

here is the sample data of changeInfoQueue queue.

<Info TypeofChange="Add" ObjectType="Customer" ObjectId="0005" />
<Info TypeofChange="Add" ObjectType="Customer" ObjectId="0006" />
<Info TypeofChange="Add" ObjectType="Customer" ObjectId="0007" />
<Info TypeofChange="Add" ObjectType="Photo" ObjectId="01a243f5-4894-4d99-8238-9c4cd3" />

My Question :

  • I need to sort out changeInfoQueue based on ObjectType. How can i do that?

My findings:

  • I found OrderBy . Is it possible to use it? If so, how?

In addition to that I found priorityQueue. What is the best solution for me?

EDIT:

The values of this queue are added when relevant objects are created. (projects, borders etc.) and saves it in a local XML file. After that it needs to write to a database. This is accomplished by using a thread and when we save this data it must be saved in particular order to avoid foreign key violations. So this thread is used to call those relevant methods.

I used orderby as follows:

Queue<ChangeInfo> changeInfoQueue2 = changeInfoQueue.OrderBy(ChangeInfo => ChangeInfo.ObjectType);

then it throws following exception:

Cannot implicitly convert type ‘System.Linq.IOrderedEnumerable’ to ‘System.Collections.Generic.Queue’. An explicit conversion exists (are you missing a cast?)

  • 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-17T15:36:22+00:00Added an answer on June 17, 2026 at 3:36 pm

    Why would you want to order by the type of object in a queue? A queue, by its definition, it’s not meant to be ordered in that way but intended to work as a first in first out kind of element.

    Either use a List if you just want a collection capable of being ordered, and ordered list or create several queues for the different kind of objects that you have.

    For example, if you go to the super market you have several queues, one for each different section… it wouldn’t make any sense to put all people in the same queue and then “order” them based on whether they are in for the butcher or the bakery.

    You have a queue when you need to “queue” things… if you don’t use the appropriate construct, don’t try to force it into a queue. (“if you have a hammer everything looks like a nail”… but it should not)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched this site and Google and even though the idea is pretty
I can't seem to find this information in other questions, even though I think
Even though I have a fermi card(gtx 560) I get this error on VS2010:
I have this error appearing in my web service and even though I'v had
I'm sorry, but I'm sure this sounds like a stupid question but could someone
Update: Ehh -- Even though this question isn't answered, I've just emptied my pockets
I asked this question a while back and even though I put up several
This question sounds simple, but I'm an expert with CSS and I'm thinking it's
I know this question sounds weird, but please, let me explain myself. I'm using
Just so it's known, this question is mostly academic, even though I tried to

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.