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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:12:28+00:00 2026-05-20T00:12:28+00:00

My question is for feedback on making sure I am taking the right approach,

  • 0

My question is for feedback on making sure I am taking the right approach, and handling the threading correctly. I have a feeling I may need to set of some of my own threads, so all feedback is welcome.

The problem I have is reading RFID tags from zero or more RFID readers. I can read for a single reader without an issue so reading from several will not be an issue. Each Tag or batch of Tags read by the reader is delivered by a .Net Event.

My plan is to setup a ReaderControl class, which maintains the readers, connection, starting, stopping, etc. This class will listen to the TagRead events from the readers. On each event it handles (roughly every 250ms) it puts the read tag ids (a string) into a HashSet to keep them unique, the HashSet is located in ReaderControl. The ReaderControl will contain a timer, that fires/elapses every 500ms, this TimerElapsed event is handled by the ReaderControl which will package up the tags read from all readers so far and raise a TagsRead event. The purpose of this is to keep event firing to a minimum and reduce duplicate tags.

The TagsReads event is handled by another class called TagTranslator. This class will loop through the tag ids (strings) and work out what the tag refers to, i.e. IPerson object. This class will fire an event on completion of the translation with a PeopleSeen event.

The PeopleSeen event is handled by a model in a GUI (MVP pattern). The overall idea is a GUI display is shows names of people which pass through the RFID readers. The display is simply but obviously under the hoods tags are being read in asych and been translated to “real” objects to be displayed.

Do you feel ReaderControl should be running on its own thread, I think it should. How do I go about packaging this class in its own thread to just keep reading tags regardless of what the GUI is doing. Also, do you think when the TagTranslator when handling events should create threads to handle the translation.

  • 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-05-20T00:12:28+00:00Added an answer on May 20, 2026 at 12:12 am

    I would suggest that, rather than using events, you use a concurrent queue data structure and a multiple producer, single consumer model. Think of the tag reader threads as producers, and the processing thread as consumers.

    When a thread receives a tag from a reader, it adds that tag to the queue, not worrying about duplicates or anything. Heck, you might want that duplicate information at some point. No reason to throw it out right here.

    The consumer waits on the queue, taking items off and processing them one at a time.

    The BlockingCollection class is perfect for this.

    // Shared queue.  Assuming that a tag is simply a string.
    BlockingCollection<string> TagQueue = new BlockingCollection<string>();
    
    // Tag reader threads (producers)
    while (!ShutdownMessageReceived)
    {
        string tag = GetTagFromReader(); // however that's done
        TagQueue.Add(tag);
    }
    
    // Processing thread (consumer)
    while (!ShutdownMessageReceived)
    {
        string tag = TagQueue.Take();
        // process the tag
    }
    

    BlockingCollection supports multiple producers and consumers, so you can have as many of each as you like. The Take method will block until an item is available. It’s a non-busy wait, so there’s no polling overhead.

    This kind of thing is very easy to implement with BlockingCollection, and makes for clean and simple code that performs very well.

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

Sidebar

Related Questions

I have a design question. I want some feedback to know if a ThreadPool
I had posted the question once to http://doctype.com/within-same-line-have-center-element-right-most-element , but didn't get a good
After feedback, complete rewrite of the question. I have the following mark up :
Based on feedback I got from this question , I'm interested in using Lazy
Question Is there a way to have a method that will always run anytime
Earlier I requested some feedback on my first F# project. Before closing the question
This is a general question, but I'd love some feedback. I'm new to working
I have a feedback form which will take a couple of user inputted fields
Simple (I hope), HTML question. Let's say I have a column group that spans
I need to sort some products base on user ratings. Suppose we have 3

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.