473,761 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Legacy Code interface - asynchronous callaback & __pin pointer

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.
Nov 15 '05 #1
1 2097

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.publi c.dotnet.langua ges.csharp
| NNTP-Posting-Host: 130.99.229.109
| Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP12.phx.g bl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1875 60
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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.
|
|
|

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1223
by: inetmug | last post by:
Hello: I am using ASP.NET as our front end. I also have to interface to some legacy systems that use a callback mechanism. The legacy systems use callbacks (via CORBA) to communicate back to clients. The ASP.NET web pages will initiate communication with the legacy backend, but results from the backend will often take quite some time and will be asynchronous in nature in their return. We have successfully created a prototype that...
3
1766
by: masood.iqbal | last post by:
In this day and age, you never say no to any work that is thrown at you ---- so when I was offered this short-term contract to convert legacy C code to C++, I did not say no. Personally I believed that it was a somewhat futile exercise since one of the main requirements was for the existing API (a functional interface written in C) to remain the same. I would have much rathered that the mandate be ab-initio, but that was not the case...
3
4022
by: Sai Kit Tong | last post by:
Hi, I am developing a new application running on Windows platform that needs to interface with existing legacy code - written in basic C / C++. I am trying to evaluate Java vs C# implementations. Originally, I have the impression that C# should be a clear winner. I started with Java and using the guideline from the book "Java Native Interface". Though complex, the book provide details of the practical implementation and potential...
3
2377
by: Sai Kit Tong | last post by:
I posted for help on legacy code interface 2 days ago. Probably I didn't make it clear in my original mail. I got a couple of answers but none of them address my issues directly (See attached response). My first reply directed me to source code migration but I didn't have the source code. The second reply mentioned about .NET interoperability (PInvoke I think) but I MENTIONED THAT I COULDN'T FIND ANY DOCUMENTATION FROM MSDN LIBRARY BASED ON...
4
2402
by: Sai Kit Tong | last post by:
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...
1
1523
by: Steve Baer | last post by:
I'm wrapping some unmanaged C++ classes with managed versions for use in the ..NET world. Everything is going great except I can't figure out a good method for passing simple data type arrays into unmanaged classes. Say I have a function void UnManagedClass::FillOutArray(int size, int* data); where data is an array of unmanaged ints and size gives the size of the array. I would like to wrap the function like so
7
1933
by: Ioannis Vranos | last post by:
I have been checking C++/CLI lately by using VC++ 2005 Express Beta 1 (should be called Alpha though). In managed extensions we could pass managed pointers to functions taking unmanaged pointers as parameters by using __pin pointers: __gc class whatever { // ...
2
1643
by: Mark Olbert | last post by:
First off, the sympathy is for all you poor buggers out there who have to figure out how to marry Managed Extensions for C++ onto your legacy code. My condolences; my brief experience with the process leads me to believe the Microsoft hates all of its VC++ developers :) Now, the question. I'm getting a NullReferenceException in a __gc class that wraps functionality in a legacy C/C++ app (it's actually part of the Nero burning rom api). ...
7
1821
by: Ben Finney | last post by:
Howdy all, I'm working on a web application that is starting to gain a lot of back-end code written in Python. However, all the current interface code is written in legacy PHP. I'd like to slowly introduce new features as Python WSGI programs. Is it possible to write a Python WSGI program that talks to a PHP program as its "back end"? Where can I find out how to do this, preferably with examples?
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9336
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9765
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3866
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.