Is there any way you can post a small trivial example of
the first Q&A post? We are currently having
problems with some (strangely not all though) delegate
callbacks when we mix managed/unmanaged code. This is
how we have been doing it in sorta-psuedo-code.
Say our managed Forms app has a function
private void AddListViewItem(ListViewItem * lvi)
{
...
}
and we declare/create a delegate...
public __delegate void AddDelegate(ListViewItem * lvi);
AddDelegate * myAD;
myAD = new AddDelegate(this,AddListViewItem);
Now we can pass a pointer to this class to our unmanaged
classes using the <gcroot> mechanism, and
then call the delegate.
Object * [] o = {listViewItem1};
_parent->Invoke(_parent->myAD,o);
This works flawlessly in some cases, calling back in on
the correct thread etc., but in other cases we get
constant exceptions of the "The Application has
requested that the runtime terminate it in an unusual
way...". Is there something obviously wrong
with this? MSDN suggests this as the only way to insure
thread safety (and prevent crashes other weird behavior)
with Forms controls.