calling unmanaged dll

  • Thread starter Thread starter adrin
  • Start date Start date
A

adrin

hello,
im calling a function from an unmanaged dll which takes a ref to structure
as an argument.
one of the struct's fields is an address to a callback function/event(it
depends on you what to choose). It works asynchronously, modyfies given
structure and calls callback/event when finished.

How can i make it work in c#? can i use events?
Can i wait for the dll function to finish within c# method that called it?
Do i declare address to a function in structure as an IntPtr?

please help a newbie :)
 
Have a look at delegates. Create a delegate like this

delegate void MyDelegate (int param);

use it in the declare like this

extern void MyDeclare(MyDelegate Address)

call it like this

MyDeclare(new MyDelegate(CallBackFunc))

void CallBackFunc(int someparam)
{
//callback will come here.
}
 
Back
Top