ToHfont problem

  • Thread starter Thread starter tommy
  • Start date Start date
T

tommy

Hi there,

I used the floowing code to test
System.Drawing.Font.ToHfont():

int i = 0;
for(;;)
{
System.Drawing.Font font =
new System.Drawing.Font
("Arial",16,System.Drawing.FontStyle.Bold);
IntPtr hf = font.ToHfont();
Console.WriteLine
(i.ToString());
i++;
Thread.Sleep(10);

}

And I found the system broken when i reach 14000. Can
anyone explain why this happened?
 
And I found the system broken when i reach 14000. Can
anyone explain why this happened?

Because ToHFont() allocates a GDI font handle that you're not freeing,
so you're leaking resources.



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top