473,625 Members | 3,353 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I service a single class on one low priority thread?

Hi Everyone,

I was thinking of how to do this for a while now and I cant get my
head round it so I though I'd ask the experts! :-)

What I am doing is reading in large amounts of data over TCP and
saving it to disk. I receive alot of data from alot of clients so I do
all this without processing the data.

When a piece of data from a client has been completed I want to do
some processing on it and then send it off to another server. I want
to do all this in a low priority thread so as not to interfere with
the main program. What I would like to do is just add the job to a
queue and have a thread waiting ready to service the queue when a job
arrives. I may have 100 items on the queue or only 1. I just want this
thread to trundle away in the background pulling a job off the queue
processing it and then getting another job etc. If the queue is empty
then I would expect it to just sit there idle until an item is added.
Is this possible? How would I go about it or is there a better way?

Many thanks
Nov 17 '05 #1
3 1369
Erik <erik@[spamm1ngN0spamm 1ng]scrappy.freeser ve.co.uk> wrote:
I was thinking of how to do this for a while now and I cant get my
head round it so I though I'd ask the experts! :-)

What I am doing is reading in large amounts of data over TCP and
saving it to disk. I receive alot of data from alot of clients so I do
all this without processing the data.

When a piece of data from a client has been completed I want to do
some processing on it and then send it off to another server. I want
to do all this in a low priority thread so as not to interfere with
the main program. What I would like to do is just add the job to a
queue and have a thread waiting ready to service the queue when a job
arrives. I may have 100 items on the queue or only 1. I just want this
thread to trundle away in the background pulling a job off the queue
processing it and then getting another job etc. If the queue is empty
then I would expect it to just sit there idle until an item is added.
Is this possible? How would I go about it or is there a better way?


Well, see the link below for a producer/consumer queue. Then just
create a thread which is going to be the consumer, set it to be low
priority, and start it.

http://www.pobox.com/~skeet/csharp/t...eadlocks.shtml (half way
down the page)

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
Also remember that thread priority is system wide, not just application
wide. So using a lower priority may actually negatively effect your
performance. If your consumer keeps falling too behind because it is on a
lower priority, then at some point your producer(s) will out run your
consumer and either fill the queue (if bounded) or fill all memory. If your
writing to disk, this may be less of a concern. Here is an UI example I did
using my Bounded Blocking queue on Channel9:
http://channel9.msdn.com/ShowPost.aspx?PostID=50960

--
William Stacey [MVP]

"Erik" <erik@[spamm1ngN0spamm 1ng]scrappy.freeser ve.co.uk> wrote in message
news:k6******** *************** *********@4ax.c om...
Hi Everyone,

I was thinking of how to do this for a while now and I cant get my
head round it so I though I'd ask the experts! :-)

What I am doing is reading in large amounts of data over TCP and
saving it to disk. I receive alot of data from alot of clients so I do
all this without processing the data.

When a piece of data from a client has been completed I want to do
some processing on it and then send it off to another server. I want
to do all this in a low priority thread so as not to interfere with
the main program. What I would like to do is just add the job to a
queue and have a thread waiting ready to service the queue when a job
arrives. I may have 100 items on the queue or only 1. I just want this
thread to trundle away in the background pulling a job off the queue
processing it and then getting another job etc. If the queue is empty
then I would expect it to just sit there idle until an item is added.
Is this possible? How would I go about it or is there a better way?

Many thanks

Nov 17 '05 #3
Thanks guys, this was all very useful

Thanks again

On Thu, 23 Jun 2005 20:21:49 GMT, Erik
<erik@[spamm1ngN0spamm 1ng]scrappy.freeser ve.co.uk> wrote:
Hi Everyone,

I was thinking of how to do this for a while now and I cant get my
head round it so I though I'd ask the experts! :-)

What I am doing is reading in large amounts of data over TCP and
saving it to disk. I receive alot of data from alot of clients so I do
all this without processing the data.

When a piece of data from a client has been completed I want to do
some processing on it and then send it off to another server. I want
to do all this in a low priority thread so as not to interfere with
the main program. What I would like to do is just add the job to a
queue and have a thread waiting ready to service the queue when a job
arrives. I may have 100 items on the queue or only 1. I just want this
thread to trundle away in the background pulling a job off the queue
processing it and then getting another job etc. If the queue is empty
then I would expect it to just sit there idle until an item is added.
Is this possible? How would I go about it or is there a better way?

Many thanks


Nov 17 '05 #4

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

Similar topics

3
1951
by: Marty McDonald | last post by:
Using Visual Studio.Net... I have two classes, one derives from the other. My web service accepts the base class as input, it returns the derived class as the return value. When I set a web reference to that web service, the web service proxy is incorrect! It creates its own version of the base class fine, but when it creates its own version of the derived class, it shows it as simply deriving from the base, but its own members are not...
3
9075
by: Mike | last post by:
Timeout Calling Web Service I am calling a .NET 1.1 web service from an aspx page. The web service can take several minutes to complete its tasks before returning a message to the aspx page. If the web service is taking a long time to complete, the aspx page returns a ‘The operation has timed-out.’ Message to the web browser after 100 seconds. I’ve added: <httpRuntime executionTimeout="300" /> to the web.config files
5
2017
by: Gardar | last post by:
I have a .net webservice, developed with c++ managed extensions. The websrvice returns an xml-document with a reference to a server side xml-stylesheet in the format <?xml-stylesheet href = 'StyleSheet.xsl' type = 'text/xsl'?> This allows the client to retrieve the stylesheet for rendering the xml, if needed. When I test this with IE it detects the stylesheet reference and tries to get the stylesheet file with the following "GET"
2
1529
by: Peter Norregaard | last post by:
Our customers have different names SLA’s / Service Level Agreements but use the same webservice. How do I handle that some users can be allowed to wait when the load is high while others can’t? One possible scenario could be to redirect VIPs to a more powerful webfarm than the one the common user uses. But is it a good solution and, in case it is, can I implement it using some of the standard features in .net (or perhaps .net v2)? ...
2
1966
by: Tim Reynolds | last post by:
Team, We need some guidance here. We are developing a web service to expose to external system. We are not sure which is the best path to take. We have multiple input fields required and a few output fields. We are thinking to either 1) Make all input fields one class and have one parameter for our web service of this object type and make all output fields a second class and have return type of our web method return an object of this...
2
1766
by: John A | last post by:
I have a Web Service that I am reponsible for that we use for data integration purposes. Recently I have been tasked with sending some of this data to a third party. Because they need to receive the data in real time. They have requested that I subscribe to a Web Service that they have published. The only problem is that they often take longer than 30 seconds to process my data before I get a response back from them. This is taking far...
7
1755
by: Joseph Geretz | last post by:
I have a Service which runs OK, but I'm abviously not starting it properly. In my OnStart event I commence a long running process which polls a database table and performs various processing. Since this polling loop is entered synchronously from OnStart, basically the OnStart event doesn't terminate for the life of the program. This doesn't give the SCM the correct feedback that the service has started properly. Consequently, the SCM throws...
4
3400
by: Oriane | last post by:
Hi there, I need to use an ActiveX inside a Web service. My problem is that I need an handle on this Com component, so I add a reference to my .Net project, and I create an instance of class of this Com exe. But I then realize that each time I call for a method of my web service, I create a new Com exe process, which is not what I want. Any idea to avoid this pitfall ?
2
5332
by: =?Utf-8?B?bXVyYWRqYW1lcw==?= | last post by:
Yes, sorry I tried to make it clear in the original question that I want to get the user token of the service - ie. the account the service is running under. I know services don't have user tokens - I suspect users do have tokens, hence "user token", otherwise we might call them "service tokens" or somesuch :-) If you read the question again, you migh see that the fundamental question is, *assuming there is no other approach*: The...
0
8256
marktang
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...
0
8189
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,...
0
8635
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
7184
agi2029
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...
1
6118
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
5570
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
4089
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...
0
4193
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.