Tom*_*ter 5 .net wpf excel dde
我发现了一个非常奇怪的问题,如果我使用ThreadPool获取.Net应用程序的渲染层,它将从Excel挂起一个非常简单的DDE调用.在与Excel的DDE调用同时运行复杂的WPF应用程序时,会出现此问题.我已经设法在几行代码中重现了这个问题,可以在下面找到.
C#.Net App
//Need to reference PresentationCore.dll
class Program
{
private static int _renderTier;
static void Main(string[] args)
{
ThreadPool.QueueUserWorkItem(x =>
{
_renderTier = RenderCapability.Tier;
Console.WriteLine(_renderTier);
});
Console.ReadLine();
}
}
Run Code Online (Sandbox Code Playgroud)
Excel DDE宏.
Sub Using_DDE1()
' Dimension the variables.
Dim Chan As Integer
Dim RequestItems As Variant
' Start a channel to Word using the System topic.
Chan = DDEInitiate("WinWord", "System")
' Requesting information from Word using the Formats item
' this will return a one dimensional array.
RequestItems = DDERequest(Chan, "Formats")
' Uses a FOR loop to cycle through the array and display in a message box.
For i = LBound(RequestItems) To 3
MsgBox RequestItems(i)
Next i
' Terminate the DDE channel.
DDETerminate Chan
End Sub
Run Code Online (Sandbox Code Playgroud)
运行宏将在自己运行时显示3个消息框.如果我在c#app运行时尝试运行宏,它将挂起对DDEInitiate的调用.一旦c#app关闭,excel就会恢复生机.从主线程获取渲染层不会导致问题.我还注意到,如果调试器暂停,即使没有进行获取渲染层的调用,宏也会挂起.
使用带有Excel 2003,.Net3.5和.Net4的Windows Xp以及带有Excel 2010,.Net3.5和.Net4的Windows 7复制问题.
知道为什么会这样吗?这是PresentationCore.dll的错误吗?
谢谢你的帮助
[更新]
更改机器的渲染层似乎释放了这个"锁定"(之后我不得不稍稍移动窗口).我正在通过启动NetMeeting来更改渲染层,但可以通过强制显卡在显示属性中使用软件渲染来完成.
| 归档时间: |
|
| 查看次数: |
2060 次 |
| 最近记录: |