Hi Sai,
In C#, I think you can use Fixed statement to get this down.
In Managed C++, you may use GCHandler to instead.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
| From: "Sai Kit Tong" <sk****@mmm.com>
| Subject: Legacy Code interface - asynchronous callaback & __pin pointer
| Date: Fri, 26 Sep 2003 10:44:26 -0500
| Lines: 13
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <uC**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: 130.99.229.109
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:187560
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| 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 responses from this
group
| by 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.
|
|
|