[英]5 seconds delay of Clipboard.SetText call
I have simple call from legacy system, my very simple .NET win application calls 我有来自旧系统的简单调用,非常简单的.NET win应用程序调用
Clipboard.SetText("small data portion")
This call last 5 seconds. 此通话持续5秒钟。 Next SetText calls works fine.
接下来的SetText调用工作正常。
Most important (IMHO) piece of caller code (VB6): 最重要的(IMHO)呼叫者代码(VB6):
SAAttr.nLength = Len(MySAAttr)
SAAttr.bInheritHandle = 1
SAAttr.lpSecurityDescriptor = 0
CreatePipe StdOutR, StdOutW, SAAttr, 0&
SetHandleInformation StdOutR, HANDLE_FLAG_INHERIT, 0&
CreatePipe StdInR, StdInW, SAAttr, 0&
SetHandleInformation StdInW, HANDLE_FLAG_INHERIT, 0&
start.cb = Len(start)
start.hStdOutput = StdOutW
start.hStdError = StdOutW
start.hStdInput = StdInR
start.dwFlags = STARTF_USESTDHANDLES
ret = CreateProcess(0&, cmdline, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS + _
CREATE_NO_WINDOW, 0&, 0&, start, proc)
ret = WaitForSingleObject(proc.hProcess, pTimeout)
CloseHandle StdOutW
2 questions: 2个问题:
What is the reason of clipboard delay? 剪贴板延迟的原因是什么?
How to fix it (but calling process must be blocked - call from non blocking calls works fine)? 如何解决(但呼叫过程必须被阻止-来自非阻止呼叫的呼叫工作正常)?
example code: 示例代码:
Dim start1 As DateTime = Now
Clipboard.SetText("simple data")
Dim start2 As DateTime = Now
Clipboard.SetText("simple data")
Dim start3 As DateTime = Now
Clipboard.SetText("simple data")
MessageBox.Show( (start2 - start1).ToString() & vbCrLf & _
(start3 - start2).ToString() & vbCrLf & _
(Now - start3).ToString() & vbCrLf )
Results: 结果:
00:00:05.0130000 00:00:05.0130000
00:00:00 00:00:00
00:00:00 00:00:00
I had the same problem for years with VB6 when using the clipboard to transfer data to Excel when Ouutlook and/or Word was running. 多年来,当Ouutlook和/或Word运行时使用剪贴板将数据传输到Excel时,我在VB6上遇到了相同的问题。
The problem is with Office; 问题出在Office上。 you need to disable the copy multiple item to/from clipboard to speed it up.
您需要禁用将多个项目复制到剪贴板或从剪贴板复制项目以加快复制速度。
https://support.microsoft.com/en-ca/help/2817672/macro-takes-longer-than-expected-to-execute-many-individual-copy-and-p https://support.microsoft.com/zh-cn/help/2817672/macro-takes-longer-than-expected-to-execute-many-individual-copy-and-p
Hope this help. 希望能有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.