Hi Robert,
Thanks for posting in the group.
I noticed that the question is also posted in dotnet.framework group. If
you have time, please check my reply there. I will follow up in that group.
Best regards,
Yanhong Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
!From: "Robert Hooker" <rhooker@rhooker.com>
!Subject: Performance : PrintDocument / PrinterSettings / PaperSizes is
very VERY **slow**
!Date: Fri, 26 Sep 2003 09:29:35 -0600
!Lines: 36
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <uzs1TNEhDHA.1692@TK2MSFTNGP09.phx.gbl>
!Newsgroups:
microsoft.public.dotnet.framework,microsoft.public .dotnet.framework.windowsf
orms,microsoft.public.dotnet.languages.csharp
!NNTP-Posting-Host: 12.155.152.130
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
!Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:532 12
microsoft.public.dotnet.languages.csharp:187556
microsoft.public.dotnet.framework:54823
!X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
!
!Hi,
!
!I'm curious to know if I'm doing something wrong here, or if this is just
!mind-numbingly slow for a reason.
!
!In a simple WindowsFormsApplication:
!
!public Form1()
!{
! // Required for Windows Form Designer support
! InitializeComponent();
!
! PrintDocument printDoc = new PrintDocument();
! // Add each papersize name (string) to an array
! //
! // Querying printer for all its papersizes is **Slow**
! // - This loop takes about 8 seconds (!!) to execute on my machine for 14
!sizes
! ArrayList names = new ArrayList();
! PrinterSettings printer = printDoc.PrinterSettings;
! for( int i=0; i<printer.PaperSizes.Count; i++ )
! {
! PaperSize psize = printer.PaperSizes[i];
! names.Add(psize.PaperName);
! }
!}
!
!It appears that each call to printer.PaperSizes.xxxxx takes a very VERY
long
!time. I can speed that loop up by moving the printer.PaperSizes.Count up
out
!of the loop, but having to do this seems funky.
!
!Am I missing something, or is this stuff just broken for speed?
!
!Rob.
!
!
!