It is about the relationship between C++ (common code across platforms) with C# (Windows Universal App). We know that we are making a function call from C++ to C# .
WITH#
class FooCS { FooCS() { FooC c = new ref FooC(); c.m_GetSomeValueEvent = GetSomeValueEvent;
C ++
public delegate Platform::String GetSomeValueEventHandler(); class FooC { public: event GetSomeValueEventHandler^ m_GetSomeValueEvent; void someFunction(){ Platform::String^ str = m_GetSomeValueEvent();
The above is very straightforward. But the problem is that this GetSomeValueEvent() in C# performs some heavy tasks, such as reading data from a database, and I have to do this async .
async Task<string> GetSomeValueEvent() {
Now the question is: how do I return C++ to return this delegate function? In another word, what should be the next signature should be changed to?
public delegate Platform::String GetSomeValueEventHandler();
I work in search engines and cannot find the correct terminology for this problem. If you know for sure that this is impossible, it would be at least nice to know.
In the end , this is what we do:
string GetSomeValueEvent() {
You must ensure that GetSomeValueEvent does not work in the main thread to prevent a deadlock.
source share