papersources and papersizes really slow on some systems.

J

joe shapiro

On some systems, particularly Vista x64 systems, it takes forever (5 to 15
seconds if compiled for x64, 10-20 seconds if compiled for x86) to enumerate
either the papersources or papersizes collection of a printersettings object.

Almost all of that time is spent before the first iteration, that is, I
guess it is setting up the enumerator. Once into the for loop, each
subsequent iterationy is very fast.

On other systems, it seems to be quite fast.

I am using visual studio .net 2008, targetting platform 2.0.

I have pasted some code below, and the output.

ANY insight or pointers would be much appreciated.

Thanks,
Joe Shapiro

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
prev = Now
TextBox1.Text = ""
TextBox1.Refresh()

mark("start")
Dim ps As New Printing.PrinterSettings
mark("before each printer")

For Each pr As String In Printing.PrinterSettings.InstalledPrinters
mark("")
mark("before name=" & pr)
ps.PrinterName = pr

mark("")
mark("before each papersource")
For Each sou As Printing.PaperSource In ps.PaperSources
mark(">>" & sou.SourceName & " " & CInt(sou.RawKind))
Next

mark("")
mark("before each papersize")
For Each sz As Printing.PaperSize In ps.PaperSizes
mark(">>" & sz.PaperName & " " & CInt(sz.RawKind))
Next
Next

End Sub

Dim prev As Date
Sub mark(ByVal str As String)
Dim e As Double
e = Now.Subtract(prev).TotalMilliseconds / 1000
TextBox1.AppendText(e.ToString("000.000") & ": " & str & vbCrLf)
prev = Now
End Sub
End Class


000.012: start
000.001: before each printer
000.015:
000.000: before name=Microsoft XPS Document Writer
000.001:
000.001: before each papersource
009.214: >>Automatically Select 15
000.000:
000.001: before each papersize
010.585: >>Letter 1
000.000: >>Letter Small 2
000.000: >>Tabloid 3
000.000: >>Ledger 4
000.000: >>Legal 5
000.000: >>Statement 6
000.000: >>Executive 7
000.000: >>A3 8
000.000: >>A4 9
000.001: >>A4 Small 10
000.000: >>A5 11
000.000: >>B4 (JIS) 12
000.000: >>B5 (JIS) 13
000.000: >>Folio 14
000.000: >>Quarto 15
000.000: >>10x14 16
000.000: >>11x17 17
000.000: >>Note 18
000.000: >>Envelope #9 19
000.000: >>Envelope #10 20
000.000: >>Envelope #11 21
000.000: >>Envelope #12 22
000.000: >>Envelope #14 23
000.000: >>C size sheet 24
000.000: >>D size sheet 25
000.000: >>E size sheet 26
000.000: >>Envelope DL 27
000.000: >>Envelope C5 28
000.000: >>Envelope C3 29
000.000: >>Envelope C4 30
000.000: >>Envelope C6 31
000.000: >>Envelope C65 32
000.000: >>Envelope B4 33
000.000: >>Envelope B5 34
000.000: >>Envelope B6 35
000.000: >>Envelope 36
000.000: >>Envelope Monarch 37
000.000: >>6 3/4 Envelope 38
000.000: >>US Std Fanfold 39
000.000: >>German Std Fanfold 40
000.000: >>German Legal Fanfold 41
000.000: >>B4 (ISO) 42
000.000: >>Japanese Postcard 43
000.000: >>9x11 44
000.000: >>10x11 45
000.000: >>15x11 46
000.000: >>Envelope Invite 47
000.000: >>Letter Extra 50
000.000: >>Legal Extra 51
000.000: >>A4 Extra 53
000.000: >>Letter Transverse 54
000.000: >>A4 Transverse 55
000.000: >>Letter Extra Transverse 56
000.000: >>Super A 57
000.000: >>Super B 58
000.000: >>Letter Plus 59
000.000: >>A4 Plus 60
000.000: >>A5 Transverse 61
000.000: >>B5 (JIS) Transverse 62
000.000: >>A3 Extra 63
000.000: >>A5 Extra 64
000.000: >>B5 (ISO) Extra 65
000.000: >>A2 66
000.000: >>A3 Transverse 67
000.000: >>A3 Extra Transverse 68
000.000: >>Japanese Double Postcard 69
000.000: >>A6 70
000.000: >>Japanese Envelope Kaku #2 71
000.000: >>Japanese Envelope Kaku #3 72
000.000: >>Japanese Envelope Chou #3 73
000.000: >>Japanese Envelope Chou #4 74
000.000: >>Letter Rotated 75
000.000: >>A3 Rotated 76
000.000: >>A4 Rotated 77
000.000: >>A5 Rotated 78
000.000: >>B4 (JIS) Rotated 79
000.000: >>B5 (JIS) Rotated 80
000.000: >>Japanese Postcard Rotated 81
000.000: >>Double Japan Postcard Rotated 82
000.000: >>A6 Rotated 83
000.000: >>Japan Envelope Kaku #2 Rotated 84
000.000: >>Japan Envelope Kaku #3 Rotated 85
000.001: >>Japan Envelope Chou #3 Rotated 86
000.000: >>Japan Envelope Chou #4 Rotated 87
000.000: >>B6 (JIS) 88
000.000: >>B6 (JIS) Rotated 89
000.000: >>12x11 90
000.000: >>Japan Envelope You #4 91
000.000: >>Japan Envelope You #4 Rotated 92
000.000: >>PRC Envelope #1 96
000.000: >>PRC Envelope #3 98
000.001: >>PRC Envelope #4 99
000.000: >>PRC Envelope #5 100
000.007: >>PRC Envelope #6 101
000.000: >>PRC Envelope #7 102
000.000: >>PRC Envelope #8 103
000.000: >>PRC Envelope #9 104
000.000: >>PRC Envelope #10 105
000.000: >>PRC Envelope #1 Rotated 109
000.000: >>PRC Envelope #3 Rotated 111
000.000: >>PRC Envelope #4 Rotated 112
000.000: >>PRC Envelope #5 Rotated 113
000.000: >>PRC Envelope #6 Rotated 114
000.000: >>PRC Envelope #7 Rotated 115
000.000: >>PRC Envelope #8 Rotated 116
000.000: >>PRC Envelope #9 Rotated 117
000.000:
000.000: before name=Fax
000.000:
000.000: before each papersource
008.301: >>Default 1
000.000:
000.000: before each papersize
010.709: >>Letter 1
000.000: >>Letter Small 2
000.000: >>Legal 5
000.000: >>Statement 6
000.000: >>Executive 7
000.000: >>A4 9
000.000: >>A4 Small 10
000.000: >>A5 11
000.001: >>B5 (JIS) 13
000.000: >>Folio 14
000.001: >>Quarto 15
000.000: >>Note 18
000.000: >>Envelope #9 19
000.000: >>Envelope #10 20
000.000: >>Envelope #11 21
000.000: >>Envelope #12 22
000.000: >>Envelope #14 23
000.000: >>Envelope DL 27
000.000: >>Envelope C5 28
000.000: >>Envelope C6 31
000.000: >>Envelope C65 32
000.000: >>Envelope B5 34
000.000: >>Envelope B6 35
000.000: >>Envelope 36
000.001: >>Envelope Monarch 37
000.000: >>6 3/4 Envelope 38
000.000: >>German Std Fanfold 40
000.000: >>German Legal Fanfold 41
000.000: >>Japanese Postcard 43
000.000: >>Reserved48 48
000.000: >>Reserved49 49
000.000: >>Letter Transverse 54
000.000: >>A4 Transverse 55
000.000: >>Letter Plus 59
000.000: >>A4 Plus 60
000.000: >>A5 Transverse 61
000.000: >>B5 (JIS) Transverse 62
000.000: >>A5 Extra 64
000.000: >>B5 (ISO) Extra 65
000.000: >>Japanese Double Postcard 69
000.000: >>A6 70
000.000: >>Japanese Envelope Kaku #3 72
000.000: >>Japanese Envelope Chou #3 73
000.000: >>Japanese Envelope Chou #4 74
000.000: >>A5 Rotated 78
000.000: >>Japanese Postcard Rotated 81
000.000: >>Double Japan Postcard Rotated 82
000.000: >>A6 Rotated 83
000.000: >>Japan Envelope Chou #4 Rotated 87
000.000: >>B6 (JIS) 88
000.000: >>B6 (JIS) Rotated 89
000.000: >>Japan Envelope You #4 91
000.000: >>PRC 16K 93
000.000: >>PRC 32K 94
000.000: >>PRC 32K(Big) 95
000.000: >>PRC Envelope #1 96
000.000: >>PRC Envelope #2 97
000.000: >>PRC Envelope #3 98
000.000: >>PRC Envelope #4 99
000.000: >>PRC Envelope #5 100
000.000: >>PRC Envelope #6 101
000.000: >>PRC Envelope #7 102
000.000: >>PRC Envelope #8 103
000.000: >>PRC 32K Rotated 107
000.000: >>PRC 32K(Big) Rotated 108
000.000: >>PRC Envelope #1 Rotated 109
000.000: >>PRC Envelope #2 Rotated 110
000.000: >>PRC Envelope #3 Rotated 111
000.000: >>PRC Envelope #4 Rotated 112
000.000:
000.000: before name=\\js939\laser
000.000:
000.000: before each papersource
015.470: >> Automatically Select 15
000.001: >> Printer Auto Select 257
000.000: >> Manual Feed in Tray 1 258
000.000: >> Tray 1 259
000.000: >> Tray 2 260
000.000: >>Unspecified 1275
000.000: >>Plain 1274
000.000: >>HP Multipurpose Paper 1273
000.001: >>HP Office Paper 1272
000.000: >>HP All-in-one Printing 1271
000.000: >>HP LaserJet Paper 1270
000.000: >>HP Premium Choice Laser 1269
000.000: >>Preprinted 1268
000.000: >>Letterhead 1267
000.000: >>Transparency 1002
000.000: >>Prepunched 1266
000.001: >>Labels 1265
000.000: >>Bond 1264
000.000: >>Recycled 1263
000.000: >>Color 1262
000.000: >>Light 60-75 g/m2 1261
000.000: >>Heavy 90-105 g/m2 1260
000.000: >>Cardstock 105-176 g/m2 1259
000.000: >>Envelope 1258
000.000: >>Rough 1257
000.000:
000.000: before each papersize
021.146: >>Letter 1
000.000: >>Legal 5
000.000: >>Executive 7
000.000: >>A3 8
000.000: >>A4 9
000.000: >>A5 11
000.000: >>B4 (JIS) 12
000.000: >>B5 (JIS) 13
000.000: >>11x17 17
000.000: >>Envelope #10 20
000.000: >>Envelope DL 27
000.000: >>Envelope C5 28
000.000: >>Envelope B5 34
000.000: >>Envelope Monarch 37
000.000: >>A6 70
000.000: >>Double Japan Postcard Rotated 82
000.001: >>B6 (ISO) 131
000.000: >>B5 (ISO) 133
000.000: >>Postcard (JIS) 134
000.000: >>8.5x13 135
000.000: >>16K 195x270 mm 136
000.000: >>16K 184x260 mm 137
000.000: >>16K 197x273 mm 139
000.000: >>8K 273x394 mm 143
 
J

joe shapiro

joe shapiro said:
On some systems, particularly Vista x64 systems, it takes forever (5 to 15
seconds if compiled for x64, 10-20 seconds if compiled for x86) to enumerate
either the papersources or papersizes collection of a printersettings object.

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=2393105
 

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

Similar Threads


Top