S
Sai Kit Tong
I have to interface managed application with my legacy dll. I have employed
the wrapper approach but I have to deal with the asynchronous callback from
the legacy dll, which likely goes through a thread other than the initial
calling thread. I got the idea from MSDN and other articles
on using the delegate. However, for garabage collection issue, I need to pin
the delegate. Since my callback is asynchronous, I have been thinking about
create that __pin pointer within my wrapper and route the callback
through the wrapper class member function. However, .NET doesn't allow a
__pin pointer data member. What should be the proper practice to prevent
that callback delegate from being moved by garbage collection? The callback
existance have to last for the lifetime of the application - HW events.
If the callback is created for an instance method, do we have to pin both
the delegate and the object itself?
the wrapper approach but I have to deal with the asynchronous callback from
the legacy dll, which likely goes through a thread other than the initial
calling thread. I got the idea from MSDN and other articles
on using the delegate. However, for garabage collection issue, I need to pin
the delegate. Since my callback is asynchronous, I have been thinking about
create that __pin pointer within my wrapper and route the callback
through the wrapper class member function. However, .NET doesn't allow a
__pin pointer data member. What should be the proper practice to prevent
that callback delegate from being moved by garbage collection? The callback
existance have to last for the lifetime of the application - HW events.
If the callback is created for an instance method, do we have to pin both
the delegate and the object itself?