Click here to Skip to main content
14,635,007 members
Home » Discussions » C#
   

C#

 
AnswerRe: WindowsMediaPlayer Pin
Christian Graus12-Jun-09 20:46
mveChristian Graus12-Jun-09 20:46 
General[Message Deleted] Pin
hkjghkj112-Jun-09 21:04
Memberhkjghkj112-Jun-09 21:04 
GeneralRe: WindowsMediaPlayer Pin
Christian Graus12-Jun-09 22:21
mveChristian Graus12-Jun-09 22:21 
QuestionPrinter Settings Pin
Kim061812-Jun-09 19:58
MemberKim061812-Jun-09 19:58 
AnswerRe: Printer Settings Pin
DavidKiryazi12-Jun-09 20:02
MemberDavidKiryazi12-Jun-09 20:02 
AnswerRe: Printer Settings Pin
Dr.Walt Fair, PE12-Jun-09 20:12
subeditorDr.Walt Fair, PE12-Jun-09 20:12 
QuestionDownload Speed Pin
gonzalodiaz12-Jun-09 18:51
Membergonzalodiaz12-Jun-09 18:51 
AnswerRe: Download Speed Pin
Luc Pattyn12-Jun-09 19:23
sitebuilderLuc Pattyn12-Jun-09 19:23 
Who is responsible for that mess?
Have you checked the CPU activity, say with Task Manager?
if it is high and you don't get real bandwidth, it indicates you are wasting lots of CPU cycles.

Here are some pointers:

1.
Every iteration of the while loop, you create a new buffer (even when no data available); you read data into it, then trim the entire buffer, i.e. you scan all of it to find out it is empty or only partially filled, whereas Read did return the exact length.

2.
Every iteration of the while loop, you perform an enc.GetBytes() on a string that is always growing; however you already know the previous length, and how much got added. IMO you don't need GetBytes at all.

3.
StringBuilder is said to be cheaper than string for a sequence of operations. However, when it needs to grow, it doubles its capacity by allocating a new array and copying all the data; you can create a StringBuilder with a specific initial capacity, reducing/avoiding the need for such copies.


Suggestions:

1.
with ASCII encoding, what would be the difference between the number of bytes received, and the number of characters in the final text?

2.
throw your code away, and start afresh.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.

GeneralRe: Download Speed Pin
Guffa12-Jun-09 20:08
MemberGuffa12-Jun-09 20:08 
QuestionDatabase query Pin
rht8612-Jun-09 18:47
Memberrht8612-Jun-09 18:47 
AnswerRe: Database query Pin
Luc Pattyn12-Jun-09 19:09
sitebuilderLuc Pattyn12-Jun-09 19:09 
QuestionMagical persistence Pin
Peter Trevor12-Jun-09 18:12
MemberPeter Trevor12-Jun-09 18:12 
AnswerRe: Magical persistence Pin
Luc Pattyn12-Jun-09 18:21
sitebuilderLuc Pattyn12-Jun-09 18:21 
GeneralRe: Magical persistence Pin
Peter Trevor13-Jun-09 13:25
MemberPeter Trevor13-Jun-09 13:25 
AnswerRe: Magical persistence Pin
Henry Minute13-Jun-09 2:35
MemberHenry Minute13-Jun-09 2:35 
GeneralRe: Magical persistence Pin
Peter Trevor13-Jun-09 13:23
MemberPeter Trevor13-Jun-09 13:23 
GeneralRe: Magical persistence Pin
Peter Trevor23-Jun-09 12:59
MemberPeter Trevor23-Jun-09 12:59 
AnswerRe: Magical persistence Pin
Peter Trevor9-Oct-09 7:00
MemberPeter Trevor9-Oct-09 7:00 
QuestionPrint Barcode Pin
samulong12-Jun-09 18:03
Membersamulong12-Jun-09 18:03 
AnswerRe: Print Barcode Pin
DavidKiryazi12-Jun-09 19:57
MemberDavidKiryazi12-Jun-09 19:57 
GeneralRe: Print Barcode Pin
OriginalGriff12-Jun-09 23:20
mveOriginalGriff12-Jun-09 23:20 
JokeRe: Print Barcode Pin
DavidKiryazi12-Jun-09 23:40
MemberDavidKiryazi12-Jun-09 23:40 
GeneralRe: Print Barcode Pin
OriginalGriff13-Jun-09 0:00
mveOriginalGriff13-Jun-09 0:00 
AnswerRe: Print Barcode Pin
Christian Graus12-Jun-09 20:34
mveChristian Graus12-Jun-09 20:34 
QuestionZooming picturebox not updating Pin
jisan2212-Jun-09 14:13
Memberjisan2212-Jun-09 14:13 

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.