DisposableAction and Marshal.ReleaseComObject
performing some Interop operations and the code is of type
try
{
selection = getSelected(Return.Some.Office.InteropObject);
for ( int i = 0 ; i < selection.count ; i++)
yield return selection.item(i)
}
finally
{
Marshal.ReleaseComObject(selection);
}
Wondering if this is a good idea, replace it with DisposableAction and change to
using ( var a = new DisposableAction(getSelected(Return.Some.Office.InteropObject)) )
{
foreach(var b in a.Items)
yield return b;
}
+3
source to share
No one has answered this question yet
See similar questions:
or similar: