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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:04:17+00:00 2026-06-04T13:04:17+00:00

Okay, this is a pretty weird question, but the situation is this. I’ve got

  • 0

Okay, this is a pretty weird question, but the situation is this. I’ve got a communication library I’ve been working on, and one of its many features is a background thread that accepts all incoming packets from a socket and doles them out as needed. In the simplest form, you can have either a request or a response to a request. Multiple threads can send on the same socket using this library by sending a request, and then waiting for a signal (event) from the background thread when its response has arrived.

You define a delegate associated with the background thread to handle what happens with incoming requests. The short of it is, you can try to send a request from this delegate. Since this is all on the same thread as the background receiving thread, it becomes deadlocked (the thread will block, waiting for its response, which will never happen). These are situations I and most people know to avoid, but I would love to have a way to throw an exception, or maybe have a compile time check that prevents the programmer from trying to call a certain method, the one which sends a request, from the thread that handles receiving.

  • 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-04T13:04:18+00:00Added an answer on June 4, 2026 at 1:04 pm

    You can name Your thread

    Thread.CurrentThread.Name = "Any name you like";
    

    Or you can create a static field to hold Your thread Id

    SomeClass.RequestSenderThreadId = Thread.CurrentThread.ManagedThreadId;
    

    And then in Your method

    if(SomeClass.RequestSenderThreadId == Thread.CurrentThread.ManagedThreadId)
    {
        throw new OperationException("You cant use this method in this thread");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

okay this might be a pretty lame and basic question but its stuck in
Okay, I need help. I'm usually pretty good at SQL queries but this one
Okay, This one is pretty simmilar to my last one, but I don't get
Okay this is my 4th question today on Scheme, still pretty new to Scheme,
Okay at first I thought this would be pretty straightforward. But I can't think
Okay this may be a simple question but I have yet to come with
Okay, this one is pretty obvious to everyone who use Django and frequently asked
Okay this one's pretty straightforward. I'm creating a checkbox in my Page.xaml.cs file, and
Okay, this is pretty weird. I made an app that listens for changes inside
Okay, I'm pretty sure that this is not possible but a client had asked

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.