Click here to Skip to main content
15,922,650 members
Home / Discussions / C#
   

C#

 
GeneralRe: PowerShell Query Pin
ChrisKo16-May-08 7:36
ChrisKo16-May-08 7:36 
GeneralRe: PowerShell Query Pin
Kevin McFarlane16-May-08 8:13
Kevin McFarlane16-May-08 8:13 
QuestionControl for handling a lot of Images Pin
anderslundsgard15-May-08 22:09
anderslundsgard15-May-08 22:09 
AnswerRe: Control for handling a lot of Images Pin
Christian Graus15-May-08 22:58
protectorChristian Graus15-May-08 22:58 
GeneralRe: Control for handling a lot of Images Pin
anderslundsgard15-May-08 23:44
anderslundsgard15-May-08 23:44 
QuestionFileStream object and performance concern Pin
rcollina15-May-08 21:30
rcollina15-May-08 21:30 
AnswerRe: FileStream object and performance concern Pin
ChrisKo16-May-08 7:35
ChrisKo16-May-08 7:35 
AnswerRe: FileStream object and performance concern Pin
The Nightcoder16-May-08 11:49
The Nightcoder16-May-08 11:49 
Hi,

It has already been said that disk I/O will most likely be your performance bottleneck anyway, making object allocation / garbage collection a non-issue from a performance point of view.

However, disposing of file streams is in my experience often critical - as the physical file will stay open (and possibly locked) until the stream is disposed (or Close()d, which is equivalent if I remember correctly - either of them kills the Win32 file handle). Unless you're the only one touching the files, this can cause problems. I routinely wrap any file I/O in using blocks when possible, in order to minimize file lock durations.

In similar scenarios I usually just enqueue what needs to be done in a Queue<my_job_type> and dequeue it from a worker thread (locking the Queue when enqueuing or dequeueing). Usually I use a Queue<my_result_type> for the results from the worker thread.

Note: The normal restriction on only locking private stuff applies, of course. Your queues should not be visible outside of your class - if people in other classes (as would be expected) enqueue things to do and dequeue results, you wrap those operations (and queue lengths or HasWorkToDo and HasResults properties or whatever feels appropriate) in methods and properties of your own class. User code calls your en-/dequeueing methods (which use lock blocks), not the ones of the actual Queues.

I usually raise an event as well whenever I have enqueued stuff to the results queue, but beware that naïve users of your class may run into problems when they touch UI stuff from the event handler if they forget to Invoke() them properly (as the event will be raised from another thread than the UI thread). You should document that if your class isn't strictly internal.

Later,

--
Peter

AnswerRe: FileStream object and performance concern Pin
rcollina16-May-08 21:37
rcollina16-May-08 21:37 
Questionhow can i make an appointment schedulling in c# Pin
mjee15-May-08 20:53
mjee15-May-08 20:53 
QuestionRe: how can i make an appointment schedulling in c# Pin
sunspeed15-May-08 20:55
sunspeed15-May-08 20:55 
AnswerRe: how can i make an appointment schedulling in c# Pin
mjee15-May-08 21:26
mjee15-May-08 21:26 
GeneralRe: how can i make an appointment schedulling in c# Pin
Rupesh Kumar Swami15-May-08 21:45
Rupesh Kumar Swami15-May-08 21:45 
GeneralRe: how can i make an appointment schedulling in c# Pin
sunspeed15-May-08 21:47
sunspeed15-May-08 21:47 
GeneralRe: how can i make an appointment schedulling in c# Pin
Shani Natav15-May-08 22:03
Shani Natav15-May-08 22:03 
AnswerRe: how can i make an appointment schedulling in c# Pin
J4amieC15-May-08 22:24
J4amieC15-May-08 22:24 
QuestionMultithreading in streaming media Pin
B!Z15-May-08 20:31
B!Z15-May-08 20:31 
AnswerRe: Multithreading in streaming media Pin
Ray Parker16-May-08 4:31
Ray Parker16-May-08 4:31 
QuestionHelp me with Tree View and TextBox [modified] Pin
kissmevn15-May-08 19:53
kissmevn15-May-08 19:53 
AnswerRe: Help me with Tree View and TextBox Pin
sunspeed15-May-08 20:31
sunspeed15-May-08 20:31 
GeneralRe: Help me with Tree View and TextBox Pin
kissmevn15-May-08 21:24
kissmevn15-May-08 21:24 
GeneralRe: Help me with Tree View and TextBox Pin
sunspeed15-May-08 21:42
sunspeed15-May-08 21:42 
GeneralRe: Help me with Tree View and TextBox Pin
kissmevn15-May-08 21:51
kissmevn15-May-08 21:51 
QuestionLong and INT64 not big enough Pin
MumbleB15-May-08 19:23
MumbleB15-May-08 19:23 
AnswerRe: Long and INT64 not big enough Pin
Christian Graus15-May-08 19:31
protectorChristian Graus15-May-08 19:31 

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.