473,626 Members | 3,265 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

queue listener

Hi

I have a system.collecti on.queue object. One thread X enque objects
into this queue and another thread Y dequeues object and process them.
I want to add a listener for this queue in thread Y so that anytime an
object is enqueued into this queue, this method could be invoked. Does
system.collecti ons.queue raises an event anytime a new item is inserted
into it? Any idea and code example will be highly appreciated.

TIA

Nov 16 '05 #1
3 4511
palm wrote:
Hi

I have a system.collecti on.queue object. One thread X enque objects
into this queue and another thread Y dequeues object and process them.
I want to add a listener for this queue in thread Y so that anytime an
object is enqueued into this queue, this method could be invoked. Does
system.collecti ons.queue raises an event anytime a new item is inserted
into it? Any idea and code example will be highly appreciated.

TIA


Hi,

No, it doesn't do anything like that. I guess you have to wrap the
existing queue in a class and add some accessor methods (Queue, Dequeue)
to it. These methods also have to make accessing the underlying queue
thread-safe. You also can't just trigger an event from the *queueing*
thread, as the event handler would run within that thread, which I
suppose is not what you want. This has to be done asynchronously. Or
if it's possible to let the consuming thread wait until the other thread
has placed an object in the queue, you could let the consuming thread
wait on an event, and wake it up after placing the object in the queue.
If that's the case, you might want to look for producer-consumer
problem. It's a classic one.

Cheers,
Benoit
Nov 16 '05 #2
Thanks for your response Benoit.

I was more thinking on these lines of something like overriding some
onInsertComplet e for the queue ( by implementing any interface .net
provide??) and raise the event from within this method. Does this sound
like a solution in .Net. Sorry if this is a stupid question but i am
novoice to .net world.
Benoit Vreuninckx wrote:
palm wrote:
Hi

I have a system.collecti on.queue object. One thread X enque objects
into this queue and another thread Y dequeues object and process them. I want to add a listener for this queue in thread Y so that anytime an object is enqueued into this queue, this method could be invoked. Does system.collecti ons.queue raises an event anytime a new item is inserted into it? Any idea and code example will be highly appreciated.

TIA

Hi,

No, it doesn't do anything like that. I guess you have to wrap the
existing queue in a class and add some accessor methods (Queue,

Dequeue) to it. These methods also have to make accessing the underlying queue thread-safe. You also can't just trigger an event from the *queueing* thread, as the event handler would run within that thread, which I
suppose is not what you want. This has to be done asynchronously. Or if it's possible to let the consuming thread wait until the other thread has placed an object in the queue, you could let the consuming thread wait on an event, and wake it up after placing the object in the queue. If that's the case, you might want to look for producer-consumer
problem. It's a classic one.

Cheers,
Benoit


Nov 16 '05 #3
palm wrote:
Thanks for your response Benoit.

I was more thinking on these lines of something like overriding some
onInsertComplet e for the queue ( by implementing any interface .net
provide??) and raise the event from within this method. Does this sound

<snip>

I got a queue class in my library that is thread-enabled, basically you
can push items into the queue and pop them off. If the queue is empty
when you try to pop off an item, the pop call will block until an item
is pushed into the queue in another thread. You also specify a maximum
size and if the queue ever becomes full, the thread that tries to push
an item into it will also block until the queue gets room for the item.

It also got timeout support so you don't have to wait indefinitely.

http://www.vkarlsen.no/lvk.net

download links up to the right in the little blue box next to the
overview post. Full source so you can just take what you need.

Fairly old release but I haven't fixed any major bugs in a while anyway.

--
Lasse Vågsæther Karlsen
http://www.vkarlsen.no/
mailto:la***@vk arlsen.no
PGP KeyID: 0x0270466B
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2776
by: phil | last post by:
And sorry I got ticked, frustrating week >And I could help more, being fairly experienced with >threading issues and race conditions and such, but >as I tried to indicate in the first place, you've >provided next to no useful (IMHO) information to >let anyone help you more than this This is about 5% of the code. Uses no locks.
1
3731
by: Cherrish Vaidiyan | last post by:
sir, I have a small error in Listener configuration.I have two system with a database in each. I am using Red Hat 9 and Oracle 9i. so i shall anme the database and system. system 1 - node2 system 2 - node3 database - apple database - intel i have installed Oracle on 'node3' by copying the files and then creating a new database in it. Now i want to configure listener. I
3
694
by: Bill | last post by:
When vb6 Winsock.RemoteHost is set to "127.0.0.1", c# socket listener cannot hear connect request (my old vb6 winsock listener could hear it...). Why doesn't this work, and is there a work around I can make on the C# side to hear the connect request? -Bill (don't reply by e-mail, the address is a fake) ______________________________ Steps to reproduce: Start the C# Listener
1
8655
by: Kishore Gopalan | last post by:
Hi, I have a strange trouble. My application sends messages to a local MSMQ Queue (say 'A') and I use a listener (a windows service) to move the messages to another local queue (say 'B') and my application polls for messages in 'B' and receives them successfully. Then, I moved the Windows Service to a remote machine and configured my application to send messages to a queue (say 'R') in that remote machine. I excpected the Windows...
6
4983
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing for long running reports. When the processing is complete it uses crystal reports to load a template file, populate it, and then export it to a PDF. It works fine so far....
7
1652
by: RobKinney1 | last post by:
Here is another question we have been meaning to post for a long time. My colleague is literally pulling chunks of hair out of his head right now. We have a logging class. This class is mutlithreaded (as required by our boss). So when we tell the class to log something, it puts the data into a queue, and logs it to the disk when it has time later (low priority thread). Its simple. As stated above, I throw data into the queue. The...
9
1748
by: Paul Rubin | last post by:
Does anyone have an implementation of a distributed queue? I.e. I have a long running computation f(x) and I'd like to be able to evaluate it (for different values of x) on a bunch of different computers simultaneously, the usual "worker thread" pattern except distributed across a network. I guess this is pretty easy to write with a centralized socket listener that dispatches requests through a Queue to multiple threads on the same...
5
38824
by: mivey4 | last post by:
Hi, First off, I am aware that this is a very heavily documented error and I have done my homework for throughly researching probable causes before deciding to post my problem here. At this point, I believe another set of eyes on the issue is merited. I am a MSSQL DBA and somewhat new to ORACLE; but I have read the administrators manual having a basic thorough level of knowledge (Tho' I am still learning) and understanding of how to...
8
8923
by: Chizl | last post by:
I'm building a web server and having some issues with the TCPListener.Start(BackLog). It doesn't seem to do as expected. I'm using MS Web Stress Tool to test against my web server and when I see 200 connections at once to it, and I'm seeing 2/3 of the sockets as socket errors.. They never get into my code, so it has to be failing on the connection side.. Backlog is the only thing I can think could be the problem. ...
0
8705
Oralloy
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...
0
8637
jinu1996
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...
0
8504
tracyyun
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...
1
6125
isladogs
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...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2625
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
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.