473,394 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 1354
Erik <erik@[spamm1ngN0spamm1ng]scrappy.freeserve.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.com>
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@[spamm1ngN0spamm1ng]scrappy.freeserve.co.uk> wrote in message
news:k6********************************@4ax.com...
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@[spamm1ngN0spamm1ng]scrappy.freeserve.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
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...
3
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. ...
5
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 =...
2
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?...
2
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...
2
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...
7
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...
4
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.