By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,422 Members | 1,455 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,422 IT Pros & Developers. It's quick & easy.

calling unmanaged dll

P: n/a
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 :)
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.
}

--
Michael Culley
"adrin" <ad***@adrin.adrin> wrote in message news:Xn*****************************@193.110.122.8 0...
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 :)

Nov 15 '05 #2

P: n/a
Here you have a description of how to implement callback functionality for
P/Invoke with a sample:

http://msdn.microsoft.com/library/de...forstrings.asp

You will just use other parameter types.

--
Cezary Nolewajka
mailto:c.*********************@no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply

"adrin" <ad***@adrin.adrin> wrote in message
news:Xn*****************************@193.110.122.8 0...
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 :)


Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.