I have a C# RTDServer that works well in one instance of excel. It is defined as follows:
[Guid("1D50EF28-A1BE-4BE9-9214-46A48085ADFF")]
[ProgId("Acme.RtdServer")]
public class RTDServer : IRtdServer
{
// IRtdServer members:
// ...
}
When the server is "connected" excel calls
#region IRtdServer Members
public int ServerStart(IRTDUpdateEvent CallbackObject)
{
_callback = CallbackObject;
}
with a callback object which can thereafter be used to notify excel that updates are available to be collected:
_callback.UpdateNotify();
The problem is that if I have a second, third etc. instance of excel, ServerStart
is never called, which means I cannot notify excel that new updates are ready.
A MS KB article here suggests similar behavior for out-of-process RTDServers.
My implementation is a threaded, in-process RTDServer.
I would like to be able to use the same server Acme.RtdServer
across multiple instances. It must be possible since the Bloomberg Excel API seems to achieve it. Does anyone know how this can be achieved?
EDIT: The calls to RTD() is wrapped in a UDF:
public object ACME_UDF(string ItemID, string TopicName, bool OtherData = false)
{
if (string.IsNullOrEmpty(ItemID) || string.IsNullOrEmpty(TopicName))
return "...";
try
{
return _xlApp.WorksheetFunction.RTD("acme.rtdserver", null, ItemID, TopicName, OtherData);
}
catch (Exception)
{
return "Failed to retrieve [" + ItemID + "] with [" + TopicName + "]";
}
}
thanks