I found a very strange problem when, if I get the .Net application rendering level using ThreadPool, it will hang a very simple DDE call from Excel. The problem occurred when starting a complex WPF application while calling DDE from Excel. I was able to reproduce the problem in a few lines of code, which can be found below.
C # .Net App
class Program
{
private static int _renderTier;
static void Main(string[] args)
{
ThreadPool.QueueUserWorkItem(x =>
{
_renderTier = RenderCapability.Tier;
Console.WriteLine(_renderTier);
});
Console.ReadLine();
}
}
Excel DDE Macro
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
3 . #, DDEInitiate. # , excel . . , , , .
Windows Xp Excel 2003,.Net3.5 .Net4 Windows 7 Excel 2010,.Net3.5 .Net4.
, ? PresentationCore.dll?
[]
, , "" ( ). , NetMeeting, , .