Answered by:
PrinterSettings/DefaultPageSettings incredibly slow on a machine

Question
-
I've hit a stumbling block on trying to figure out this problem. I have a winform app written in C# that was started back with 1.0 frame, then upgraded to 1.1, and recently I created a test 3.5 version. The deployed app is still the 1.1 as we have a lot of old 98 machines several of which don't want to upgrade to the 2.0 framework.
Here's the simplified code that I'm having problems with:
//1
PrintDocument printDocument1=new PrintDocument();
printDocument1.PrinterSettings.PrinterName=LastPrinterName;
//2
PrinterSettings ps=printDocument1.PrinterSettings;
PageSettings dps=ps.DefaultPageSettings;
string defaultsourcename=dps.PaperSource.SourceName;
//3
foreach(PaperSource p in ps.PaperSources)
comboBoxPaperSources.Items.Add(p.SourceName);
//4
string defaultsizename=dps.PaperSize.PaperName;
//5
foreach(PaperSize p in ps.PaperSizes)
comboBoxPaperSizes.Items.Add(p.PaperName);
//6
Basically my software has some 280 different reports and different ones go to different printers and to different sizes of paper. So the full code brings up an option screen that remembers the last settings and allows the user to store the settings for the specific report section and select a checkbox to not ask them for settings the next time they generate the report. The comments with numbers are to help identify how long it takes to do each section.
On my machine, a dual-core Server 2008 64 bit 4 gigs of ram, 8 printers set up, my 3.5 version in release mode takes this long:
1->2 0ms
1->3 31.2ms
1->4 46.8ms
1->5 78ms
1->6 109.2ms
On another Vista 32 bit machine, 2 gigs of ram, 12 printers set up, my 1.1 version in debug mode:
1->2 0ms
1->3 73ms
1->4 101ms
1->5 201ms
1->6 289ms
On my machine in a Hyper-V XP 32 bit window, 7 printers set up, using my 1.1 version in debug mode:
1->2 0ms
1->3 78.08ms
1->4 93.7ms
1->5 171.79ms
1->6 234.26ms
On my bosses new machine he received last week, a quad-core Vista 32 bit, 3 gigs of ram, 2 printers set up, my 3.5 version in release mode:
1->2 0ms
1->3 4,056ms
1->4 6,864ms
1->5 11,856ms
1->6 15,600ms
Using the 1.1 debug version puts 1->6 up to 17,255ms
Obviously, there's some sort of titanic problem with my bosses machine. The machine itself is incredibly fast. Every other operation in my software beats the tar timing-wise compared to my machine. As soon as it touches printers, it craps out. Wordpad/notepad/word/excel/acrobat/etc all seem to pull up printers fine. The machine is pretty "clean", all the crapware was uninstalled off of it, no virus scanner running, I've task manager killed everything non-critical. I've deleted all his printers out, reinstalled just the Microsoft XPS Document Writer. I've cleared out his temp folders and run a chkdsk. I've eliminated all the standard "this is why its slow" reasons that I know of. If it had been any other program on the machine, I would think its a windows issue, but since its just my software I'm stuck.
Does anyone have any suggestions on where to go from here?
It doesn't seem to be Vista 32 bit.
It doesn't seem to be number of printers.
It doesn't seem to be amount of ram.
It doesn't seem to be something running in the background.
It doesn't seem to be disk or printer corruption
It not affecting any "mainstream" apps
It doesn't seem to be a specific .NET framework version
So I don't know if its
Quad core and .NET
Some chunk of code I'm missing
Something I haven't thought of.Monday, July 14, 2008 1:21 PM
Answers
-
I don't have an answer, but you don't have to go beyond step 2. Time to each line of code. Debugging into the .Net source might help.
- Marked as answer by jack 321 Friday, July 18, 2008 2:21 AM
Tuesday, July 15, 2008 9:02 AM
All replies
-
I don't have an answer, but you don't have to go beyond step 2. Time to each line of code. Debugging into the .Net source might help.
- Marked as answer by jack 321 Friday, July 18, 2008 2:21 AM
Tuesday, July 15, 2008 9:02 AM -
I am having the same problem. Just enumerating papersources or papersizes takes 10+ SECONDS to reach the first iteration.
And this is on a local printer, not even a network printer.
Dim x As New Printing.PrinterSettings
x.PrinterName = cbPrinter.Text
If Not x.IsValid Then
Throw New ErrorMessage("Printer '" & cbPrinter.Text & "' is not valid.")
End If For Each s As Printing.PaperSize In x.PaperSizes
Dim n As String = s.PaperName ' **** 10+ seconds to reach here the first time.
Running vs.net 2008
compiled for x86, framework 2.0
running on vista 64 ultimate, 8gb ram
I have closed the autos and locals and watch windows
ANY CLUES would be very helpful,
Thanks.- Edited by Joe Shapiro Wednesday, October 29, 2008 7:21 PM
Tuesday, October 28, 2008 10:40 PM -
OK, I found a resolution.
It is not the framework that is slow, it is printing as a whole that is slow.
Apparrently, if you use the "add printer" wizard in vista64 (and maybe vista32?) to attach to a network printer, all access to all printing functions, even local printers, is 100x slower.
So instead, when you want to add the printer, create a local port named \\servername\printername (substituting your names of course)
Unbelievably, deleting my network printer added via the wizard, and re-adding it as above, completely solved the issue.
I can not take credit for the fix, I found it here... http://techrepublic.com.com/5208-6230-0.html?forumID=101&threadID=223424&messageID=2393105Friday, October 31, 2008 12:02 PM -
I had a similar issue in Windows 7 (super slow access to a network printer) and it turned out that enabling the bluetooth service fixed the issue...
I guess it's related to that problem: http://www.sevenforums.com/hardware-devices/8157-device-printer-panel-does-not-load.html
Wednesday, November 2, 2011 2:42 PM