我使用.NET Framework 4.8
我有一个标签 API,我使用 b-PAC SDK 来打印到标签打印机。
在这种情况下,假设 5 个人使用相同的模板在同一台标签打印机上进行打印,彼此之间最多间隔 10 秒。
但是
Open()
和 EndPrint()
即使总共需要 50 分钟才能完成。
在这种情况下,
Open()
方法需要 40 秒才能完成,EndPrint()
方法需要 50 秒才能完成。我有很多情况总共超过30分钟。
请参阅此示例的日志记录:
public void Print(string printer, string label, int copyCount, Settings settings, ILogger _logger) {
bpac.DocumentClass doc = new bpac.DocumentClass();
using (ITimer timer = _logger.Time("Open Template")) {
if (!doc.Open(string.Format(_pathTemaplate, label))) {
throw new Exception("Document couldn't be opened");
}
}
using (ITimer timer = _logger.Time("Set Printer")) {
if (!doc.SetPrinter("{printer}", false)) {
throw new Exception("Couldn't set printer");
}
}
foreach (KeyValuePair<string, string> kv in settings.Data) {
bpac.IObject field = doc.GetObject(kv.Key);
if (field == null) {
continue;
}
field.Text = kv.Value;
}
PrintOptionConstants options = PrintOptionConstants.bpoDefault;
try {
using (ITimer timer = _logger.Time("Start Print")) {
doc.StartPrint(label, options);
}
using (ITimer timer = _logger.Time("Printing")) {
for (int i = 0; i < copyCount; i++) {
doc.PrintOut(1, options);
}
}
using (ITimer timer = _logger.Time("End Print")) {
doc.EndPrint();
}
}
finally {
using (ITimer timer = _logger.Time("Close document")) {
doc.Close();
}
}
}
从本地服务器转移到云端后,Open() 和 SetPrinter() 速度变慢。 我使用 32 位 Delphi 软件已有 5 年,并注意到某些用户存在各种延迟。 即使是 P-touch 5.4 也很慢,启动 30 秒。
锁定解决方案。