COM object does not close
I am working on a stock market software (AmiBroker) plugin wherein i have
to call a COM object in order to retrieve the active symbols i.e. when
user requests for a particular symbol i have to send a Request to the
server to fetch the stock data. So, AmiBroker has exposed some functions
using COM which allows to retrieve all the symbols that have been
requested So, to get the recent symbols i have to perform a COM operation.
Code :
System.Timers.Timer tm=new Timer(1000);
tm.Elapsed += delagate(sender,e)
{
dynamic broker =
Activator.CreateInstance(Type.GetTypeFromProgID("Broker.Application",
true));
hashtable.Add(uniquernd,broker.GetActiveSymbols());
Marshal.ReleaseCOMObject(broker);
}
Note : This is how i have implemented the logic in C# (Don't find
syntactical errors in this code)
Sometimes when i close the AmiBroker app. Every COM object gets disposed
successfully but, sometimes it does stay in processes which causes
malfunctioning. Is there any alternate way to achieve this by ensuring
that the object will get disposed every time?
No comments:
Post a Comment