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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:06:53+00:00 2026-06-05T16:06:53+00:00

Monitor.Enter and Monitor.Exit are designed to be called from the same thread. But, what

  • 0

Monitor.Enter and Monitor.Exit are designed to be called from the same thread. But, what if I need to release a lock in a different thread than acquired?

For example: there are shared resource and asynchronous operation that uses this resource. The operation begins with BeginOperation and acquires the lock on the shared resource. There also the EndOperation method that releases the lock. EndOperation is typically called in another thread from a callback, thus I can’t call Monitor.Exit in the EndOperation method. What is the best approach in this case? Will double-check locking with AutoResetEvent instead of Monitor be a good solution?

  • 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-05T16:06:55+00:00Added an answer on June 5, 2026 at 4:06 pm

    Try using a ManualResetEvent, it’s used to block thead(s) until some external event has been triggered. MSDN Doc:

    http://msdn.microsoft.com/en-us/library/system.threading.manualresetevent.aspx

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

Sidebar

Related Questions

You'll appreciate the following two syntactic sugars: lock(obj) { //Code } same as: Monitor.Enter(obj)
In .NET the lock keyword is syntactic sugar around Monitor.Enter and Monitor.Exit , so
Is it possible to detect if the same thread trying to release the lock?
The ECMA-335 specification states the following: * Acquiring a lock (System.Threading.Monitor.Enter or entering a
void MethodA() { Monitor.Enter(this); if(someCondition) { Monitor.Exit(this); // This point MethodB(); } else {
I think I am missing something about correct behaviour of Monitor.Enter and Monitor.TryEnter .
In .Net4, Monitor.Enter(Object) is marked as obsolete : [ObsoleteAttribute(This method does not allow its
I am trying to monitor calls from an app to my server just like
I have several threads that write to the same int. Each thread increment the
If so, that would imply that the blocked thread can enter when another thread

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.