Click here to Skip to main content
15,887,355 members
Home / Discussions / C#
   

C#

 
QuestionContext menu for a text box. Pin
Pavan Navali17-Sep-09 1:45
Pavan Navali17-Sep-09 1:45 
AnswerRe: Context menu for a text box. Pin
Not Active17-Sep-09 1:49
mentorNot Active17-Sep-09 1:49 
GeneralRe: Context menu for a text box. Pin
Pavan Navali17-Sep-09 18:26
Pavan Navali17-Sep-09 18:26 
GeneralRe: Context menu for a text box. Pin
Not Active18-Sep-09 1:43
mentorNot Active18-Sep-09 1:43 
Questiondisabled hyperlink and write arrow cursor Pin
Idoshhh17-Sep-09 1:17
Idoshhh17-Sep-09 1:17 
AnswerRe: disabled hyperlink and write arrow cursor Pin
Not Active17-Sep-09 1:53
mentorNot Active17-Sep-09 1:53 
Questionmeasure received data/s for an udp multicast address [modified] Pin
collapo17-Sep-09 1:08
collapo17-Sep-09 1:08 
AnswerRe: measure received data/s for an udp multicast address Pin
Luc Pattyn17-Sep-09 2:32
sitebuilderLuc Pattyn17-Sep-09 2:32 
I see you have a dual-core system. Laugh | :laugh: Laugh | :laugh:

The code you created is basically a polling loop: you are repeating the same thing over and over, without waiting for anything, so the core that executes it will spin around as fast as it can: assume Available is zero, Receive sees zero-length buffer, returns immediately, timespan is very small, loop iteration done, on to the next loop wasting even more cycles.

You need to fix this in one of several ways:
- include a Thread.Sleep(x) in your code, where x>0; say x=33; that way your code will run at most 30 times per second, and your CPU usage will go way down. However you now may miss some packets.
- use a fixed-length buffer, say 2048B; that way Receive will have to wait for data; drawback is it will not report smaller packets until the buffer gets full, so there is a lag.
- use asynchronous I/O, look for BeginReceive. IMO that would be the correct way.

Smile | :)

Luc Pattyn

Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.

Local announcement (Antwerp region): Lange Wapper? Neen!


GeneralRe: measure received data/s for an udp multicast address Pin
collapo17-Sep-09 3:16
collapo17-Sep-09 3:16 
GeneralRe: measure received data/s for an udp multicast address Pin
Luc Pattyn17-Sep-09 3:23
sitebuilderLuc Pattyn17-Sep-09 3:23 
GeneralRe: measure received data/s for an udp multicast address Pin
collapo17-Sep-09 4:17
collapo17-Sep-09 4:17 
QuestionAPI in C# Pin
vahid_erad17-Sep-09 0:54
vahid_erad17-Sep-09 0:54 
AnswerRe: API in C# Pin
Calla17-Sep-09 1:11
Calla17-Sep-09 1:11 
AnswerRe: API in C# Pin
Arun Jacob17-Sep-09 1:21
Arun Jacob17-Sep-09 1:21 
AnswerRe: API in C# Pin
Harvey Saayman17-Sep-09 1:52
Harvey Saayman17-Sep-09 1:52 
QuestionOmitting HTML footer ? Pin
Mohammad Dayyan17-Sep-09 0:47
Mohammad Dayyan17-Sep-09 0:47 
AnswerRe: Omitting HTML footer ? Pin
Not Active17-Sep-09 1:45
mentorNot Active17-Sep-09 1:45 
GeneralRe: Omitting HTML footer ? Pin
Mohammad Dayyan17-Sep-09 2:12
Mohammad Dayyan17-Sep-09 2:12 
GeneralRe: Omitting HTML footer ? Pin
Not Active17-Sep-09 2:34
mentorNot Active17-Sep-09 2:34 
QuestionTCP Socket issue Pin
Harvey Saayman17-Sep-09 0:43
Harvey Saayman17-Sep-09 0:43 
AnswerRe: TCP Socket issue Pin
harold aptroot17-Sep-09 3:17
harold aptroot17-Sep-09 3:17 
GeneralRe: TCP Socket issue Pin
Harvey Saayman17-Sep-09 3:26
Harvey Saayman17-Sep-09 3:26 
GeneralRe: TCP Socket issue Pin
harold aptroot17-Sep-09 3:30
harold aptroot17-Sep-09 3:30 
GeneralRe: TCP Socket issue Pin
Harvey Saayman17-Sep-09 5:04
Harvey Saayman17-Sep-09 5:04 
GeneralRe: TCP Socket issue Pin
harold aptroot17-Sep-09 5:35
harold aptroot17-Sep-09 5:35 

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.