Click here to Skip to main content
15,886,137 members
Home / Discussions / C#
   

C#

 
GeneralRe: Simple Problem but tough for me Pin
OriginalGriff2-Sep-09 22:26
mveOriginalGriff2-Sep-09 22:26 
QuestionCultureInfo Pin
Rajee Maharjan2-Sep-09 21:12
Rajee Maharjan2-Sep-09 21:12 
AnswerRe: CultureInfo Pin
OriginalGriff2-Sep-09 21:19
mveOriginalGriff2-Sep-09 21:19 
AnswerRe: CultureInfo Pin
stancrm2-Sep-09 21:33
stancrm2-Sep-09 21:33 
QuestionAsk about <> with class name Pin
Anmar-xe2-Sep-09 20:49
Anmar-xe2-Sep-09 20:49 
AnswerRe: Ask about <> with class name Pin
Arun Jacob2-Sep-09 20:55
Arun Jacob2-Sep-09 20:55 
GeneralRe: Ask about <> with class name Pin
Anmar-xe2-Sep-09 20:57
Anmar-xe2-Sep-09 20:57 
QuestionWeird, unexplained occurance... Pin
MarkB7772-Sep-09 20:48
MarkB7772-Sep-09 20:48 
I've been working on a CRS system, and was running into a nasty error...

For some reason every ~16 or so search queries, the program would crash, and give me a WIN32 exception, telling me that my program had used up all its allocated handles.

Ok, so I wasn't disposing of my objects correctly somewhere...

After much searching, I found that the foreach loop that was disposing of the results was not working as expected. (the search results were displayed using Panels).

If I called:

<br />
int i = window.FlowPanel.Controls.Count;<br />


It would return the expected number of (say) 20.

However when I ran:

<br />
foreach (Control c in window.FlowPanel.Controls)<br />
{<br />
    c.Dispose();<br />
}<br />


It would cut out of the foreach loop at the 10th object.

If I ran the same foreach loop directly afterwards, it would cut out at the 5th object etc etc.

I solved the problem by using this snippet:

<br />
while (window.FlowPanel.Controls.Count > 0)<br />
{<br />
foreach (Control c in window.FlowPanel.Controls)<br />
{<br />
    c.Dispose();<br />
}<br />
}<br />
<br />
GC.Collect();<br />


This solved the problem, but can anyone explain this behaviour?

Cheers,


Mark.

Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

AnswerRe: Weird, unexplained occurance... Pin
OriginalGriff2-Sep-09 21:33
mveOriginalGriff2-Sep-09 21:33 
JokeRe: Weird, unexplained occurance... Pin
Greg Chelstowski2-Sep-09 21:37
Greg Chelstowski2-Sep-09 21:37 
GeneralRe: Weird, unexplained occurance... Pin
MarkB7773-Sep-09 1:13
MarkB7773-Sep-09 1:13 
AnswerRe: Weird, unexplained occurance... Pin
Greg Chelstowski2-Sep-09 21:36
Greg Chelstowski2-Sep-09 21:36 
GeneralRe: Weird, unexplained occurance... Pin
OriginalGriff2-Sep-09 21:40
mveOriginalGriff2-Sep-09 21:40 
GeneralRe: Weird, unexplained occurance... Pin
Greg Chelstowski2-Sep-09 21:44
Greg Chelstowski2-Sep-09 21:44 
GeneralRe: Weird, unexplained occurance... Pin
MarkB7773-Sep-09 1:14
MarkB7773-Sep-09 1:14 
Questiondll security Pin
amit_upadhyay2-Sep-09 20:29
amit_upadhyay2-Sep-09 20:29 
AnswerRe: dll security Pin
Arun Jacob2-Sep-09 20:37
Arun Jacob2-Sep-09 20:37 
GeneralRe: dll security Pin
amit_upadhyay3-Sep-09 6:17
amit_upadhyay3-Sep-09 6:17 
AnswerRe: dll security Pin
Arun Jacob3-Sep-09 18:06
Arun Jacob3-Sep-09 18:06 
GeneralRe: dll security Pin
amit_upadhyay3-Sep-09 22:54
amit_upadhyay3-Sep-09 22:54 
GeneralRe: dll security Pin
Arun Jacob3-Sep-09 22:56
Arun Jacob3-Sep-09 22:56 
GeneralRe: dll security Pin
mustang863-Sep-09 6:21
mustang863-Sep-09 6:21 
GeneralRe: dll security Pin
amit_upadhyay3-Sep-09 6:30
amit_upadhyay3-Sep-09 6:30 
GeneralRe: dll security Pin
mustang863-Sep-09 10:22
mustang863-Sep-09 10:22 
QuestionProblem with sorting string using radix sort [modified] Pin
gamer11272-Sep-09 20:16
gamer11272-Sep-09 20:16 

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.