Re: write delegate & callback in dll

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi James,

So you mean you need to return the value from _Add function that is
calculated on another thread to the main thread. Am I right?

To return the value, the simplest way is to set the value to a certain
variable in the _Add function instead of returning a value. And in the
callback, make the main thread read from that variable. By the way, when
setting the variable value, we have to use SyncLock statement to lock the
object to make sure that no other thread is writing to it simultanously.

For more information about SyncLock, please check the following link:

http://msdn2.microsoft.com/en-us/library/3a86s51t.aspx

If anything is unclear, please feel free to let me know.

Kevin Yu
Microsoft Online Community Support

==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

.