Click here to Skip to main content
15,881,709 members
Home / Discussions / C#
   

C#

 
QuestionThreading Question Pin
Harvey Saayman17-Dec-09 23:11
Harvey Saayman17-Dec-09 23:11 
AnswerRe: Threading Question Pin
#realJSOP17-Dec-09 23:40
mve#realJSOP17-Dec-09 23:40 
GeneralRe: Threading Question Pin
Harvey Saayman18-Dec-09 0:24
Harvey Saayman18-Dec-09 0:24 
AnswerRe: Threading Question Pin
Pete O'Hanlon18-Dec-09 0:14
mvePete O'Hanlon18-Dec-09 0:14 
GeneralRe: Threading Question Pin
Harvey Saayman18-Dec-09 2:32
Harvey Saayman18-Dec-09 2:32 
GeneralRe: Threading Question Pin
Luc Pattyn18-Dec-09 5:23
sitebuilderLuc Pattyn18-Dec-09 5:23 
GeneralRe: Threading Question Pin
Harvey Saayman18-Dec-09 5:56
Harvey Saayman18-Dec-09 5:56 
GeneralRe: Threading Question Pin
Luc Pattyn18-Dec-09 6:19
sitebuilderLuc Pattyn18-Dec-09 6:19 
sounds doable.

caveat:

Harvey Saayman wrote:
I'll shove the entire piece of data into a collection of some type


that collection will be operated upon by at least two threads (the ThreadPool thread as the only producer, and your nre new thread as the only consumer), so it will need thread-safety precautions, e.g. a Lock. So in the end any of the client threads could potentially block the PacketReceivedCallback thread.

BTW: There also is a delicate way of doing this without a lock, but it is rather hard to get it absolutely safe. You shouldn't even try it before you really need to get rid of all locks.

ADDED:

The official ThreadPool has a particular behavior in that it manages how many threads it is going to use for a particular set of "jobs" (i.e. QueueUserWorkItem() calls). It will dynamically alter the number of threads, but only at a limited pace, something like "no more than 1 extra thread per half second". Which really means work items may get a long delay before they start. That might upset your clever threading scheme and make it look like pretty slow (and even worse than a simple non-threaded approach) at first. One way around it is not to use the ThreadPool, i.e. using real explicit Threads.
BTW: I haven't seen it documented, however I have a test app to prove it; no article yet (that is planned for next year).

Smile | :)

Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


modified on Friday, December 18, 2009 2:03 PM

GeneralRe: Threading Question Pin
Harvey Saayman18-Dec-09 7:49
Harvey Saayman18-Dec-09 7:49 
Question[Message Deleted] Pin
thungphan17-Dec-09 20:53
thungphan17-Dec-09 20:53 
AnswerMessage Closed Pin
17-Dec-09 21:25
stancrm17-Dec-09 21:25 
GeneralRe: convert int to byte array using shift operator Pin
thungphan17-Dec-09 21:42
thungphan17-Dec-09 21:42 
AnswerRe: convert int to byte array using shift operator Pin
harold aptroot17-Dec-09 21:52
harold aptroot17-Dec-09 21:52 
QuestionRuntime ToFront toBack? Pin
dennis_max2717-Dec-09 20:29
dennis_max2717-Dec-09 20:29 
AnswerRe: Runtime ToFront toBack? Pin
Saksida Bojan17-Dec-09 20:37
Saksida Bojan17-Dec-09 20:37 
GeneralRe: Runtime ToFront toBack? Pin
dennis_max2717-Dec-09 20:47
dennis_max2717-Dec-09 20:47 
GeneralRe: Runtime ToFront toBack? Pin
Saksida Bojan17-Dec-09 20:50
Saksida Bojan17-Dec-09 20:50 
GeneralRe: Runtime ToFront toBack? Pin
dennis_max2717-Dec-09 20:54
dennis_max2717-Dec-09 20:54 
GeneralRe: Runtime ToFront toBack? Pin
Saksida Bojan17-Dec-09 21:00
Saksida Bojan17-Dec-09 21:00 
GeneralRe: Runtime ToFront toBack? Pin
dennis_max2717-Dec-09 21:00
dennis_max2717-Dec-09 21:00 
AnswerRe: Runtime ToFront toBack? Pin
dennis_max273-Jan-10 22:37
dennis_max273-Jan-10 22:37 
Questionparsing javascript in realtime Pin
Haim Nachum17-Dec-09 19:39
Haim Nachum17-Dec-09 19:39 
QuestionDeploying Windows Application(C#) with SQL Server(2005) Pin
samrat.net17-Dec-09 19:18
samrat.net17-Dec-09 19:18 
AnswerRe: Deploying Windows Application(C#) with SQL Server(2005) Pin
Mycroft Holmes17-Dec-09 23:26
professionalMycroft Holmes17-Dec-09 23:26 
AnswerRe: Deploying Windows Application(C#) with SQL Server(2005) Pin
PIEBALDconsult18-Dec-09 3:55
mvePIEBALDconsult18-Dec-09 3:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.