I need to use my c++ code in c# application. I thought about pinvoke, but I'm confused with the approach I should take for creating dll from my c++ app.
Basically, my c++ app is a main
function, which runs an endless loop of data processing and I dont know how I can export such thing to dll and call it from c#.
I tried to rewrite my main
function in standalone init
function for dll and call it from c#, but because its a endless loop it never came to the point with return
from function. And I dont know how to get my data buffer from endless loop at some point to my c# app.
What I've done currently:
// myDLL.cpp
int __stdcall OpenRTSP(char url, char progname)
{
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);
if (openURL(*env, &progname, &url) < 0)
{
return -1;
}
// All subsequent activity takes place within the event loop:
// This function call does not return, unless programm closes.
env->taskScheduler().doEventLoop(&eventLoopWatchVariable);
return 0;
}
// myDLL.h
__declspec(dllexport) int __stdcall OpenRTSP(char url, char progname);
I dont know how to call OpenRTSP from c#, because it will never return from this func and how to write a function, which will return me a data buffer from endless loop?