I’m writing a thread wrapper for a safe thread termination by using stop event.
Whenever the thread stop event is signaled, I want to release the thread in
case it’s blocked on Monitor.Enter() or Monitor.Wait().
Note that when I’m writing this code, I do not know on what object the
Monitor will block on.
Is there a way to release the thread from the Monitor blocking except using
Thread.Interrup t() (Any kind of wrapping is acceptable) ???
--
Thanks
Sharon G. 2 1632
Sharon,
Interrupt is the only thing that will stop the blocking. The only other
thing I could think of that would stop it would be to actually find the
object that is currently holding the lock, and release it on the thread that
is holding it. However, that doesn't guarantee that your thread will wake
up, because there might be other threads trying to lock on that same object.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Sharon" <Sh****@discuss ions.microsoft. com> wrote in message
news:50******** *************** ***********@mic rosoft.com... I'm writing a thread wrapper for a safe thread termination by using stop event. Whenever the thread stop event is signaled, I want to release the thread in case it's blocked on Monitor.Enter() or Monitor.Wait(). Note that when I'm writing this code, I do not know on what object the Monitor will block on. Is there a way to release the thread from the Monitor blocking except using Thread.Interrup t() (Any kind of wrapping is acceptable) ???
-- Thanks Sharon G.
Why do you not want to use Interrupt in this situation - thats exactly what its there for
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
I'm writing a thread wrapper for a safe thread termination by using stop event.
Whenever the thread stop event is signaled, I want to release the thread in
case it's blocked on Monitor.Enter() or Monitor.Wait().
Note that when I'm writing this code, I do not know on what object the
Monitor will block on.
Is there a way to release the thread from the Monitor blocking except using
Thread.Interrup t() (Any kind of wrapping is acceptable) ???
--
Thanks
Sharon G. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John P. Speno |
last post by:
So you have this problem, and you decide to use threads to solve it...
System is Python 2.3.3 on Solaris 9.
I'm using the classic Python thread model. Main thread puts stuff into
a Queue.Queue() and worker threads get stuff out of it and do their thing.
On occaision, I get an exception in the main thread when it tries to
put something into the Queue.
|
by: David Sworder |
last post by:
This message was already cross-posted to C# and ADO.NET, but I forgot to
post to this "general" group... sorry about that. It just occured to me
after my first post that the "general" group readers might have some
thoughts on this perplexing .NET blocking issue.
(see below)
=====
Hi,
|
by: Hagay Lupesko |
last post by:
Hi,
I've encountered a strange phenomena which appears to me as a bug:
I have an engine that uses a System.Threading.Timer to invoke a delegate
every X minutes.
The code looks something like this:
TimerCallback callBack = new TimerCallback(Run); // run is obviously a
method
|
by: Frank Rizzo |
last post by:
I tried it on dotnet.vb, but got no answers. I'll try it here now.
I have an app that listen to data on a certain resource. Data can come
in on this resource any time, so I have to listen for it the entire
time. I wanted to see if what I have is thread-safe and makes sense.
Consider the code below. The app starts and creates code to handle an
even from the Listener class. The listener class creates a new thread
(will call it thread BOB)...
|
by: Sakharam Phapale |
last post by:
Hi All,
In following example, while playing file, if thread goes in WaitSleepJoin
state, due to Thread.Sleep method.
Now I want to suspend thread by clicking on cmdSuspend button. I have
written following code, which doesn't suspend it.
Even I tried it by calling m_PlayThread.Interrupt() method which suspends
the thread but cannot resume it again by calling Resume method.
Any kind help will be appreciated.
| |
by: NG |
last post by:
Hi All
I am using interop blocking COM call from within a worker thread. This is a
part of Windows Application. I find that if I remove the blocking COM call
and instead use an infinite while loop, the Windows App works fine.
However, when I use the blocking COM call from withing the infinite while
loop, the Windows Application freezes. Can anyone please tell me what the
problem could be?
Thanks in advance for any help.
|
by: Kieran Benton |
last post by:
Hello,
I'm currently in the tail end process of developing a high scalability
server for my employer. Essentially it receives short socket based
connections with an ASCII message, parses that message, does some
processing and then sends out a string reply on the same connection.
I'm using the asynchrounous IO completion port based socket methods in
..NET 2.0 to handle the comms side of things (giving extremely good
performance) and the...
|
by: les |
last post by:
Here's a class which uses 2.0 generics to implement an inter-thread
message queue in C#. Any number of threads can post and read from the
queue simultaneously, and the message object can be any type.
There's a test driver at the bottom which demonstrates usage.
/*-----------------------------------------------------------------------------------------------------*/
using System;
using System.Collections.Generic;
|
by: sherifffruitfly |
last post by:
Hi all,
I'm trying to to figure out this stuff, and I've got part of the trick
in the code below, which updates a textbox with data from another
thread. What I'd like to do is put a Pause button on my form which
basically pauses the ReadCsv() method wherever it's at. Obviously, the
Pause button would need to be responsive to the user during while
ReadCsv() is churning. How do I do this?
Thanks for any pointers (heh-heh),
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |