Build an event, that is usable from a C# program, which belongs to a C++ program.

Pågående Publicerat 4 år sedan Betalades vid leverans
Pågående Betalades vid leverans

I have a small C++ dll which creates a CLRCreateInstance and loads a C# dll.

Here is the source:

///////////////////////////////////////////////////////////////////////////////////////////////////////

#include <metahost.h>

#pragma comment(lib, "[login to view URL]")

DWORD WINAPI ControlThread(LPVOID lpParam)

{

ICLRMetaHost* metaHost = NULL;

ICLRRuntimeInfo* runtimeInfo = NULL;

ICLRRuntimeHost* runtimeHost = NULL;

if (CLRCreateInstance(CLSID_CLRMetaHost, IID_ICLRMetaHost, (LPVOID*)&metaHost) == S_OK)

if (metaHost->GetRuntime(L"v4.0.30319", IID_ICLRRuntimeInfo, (LPVOID*)&runtimeInfo) == S_OK)

if (runtimeInfo->GetInterface(CLSID_CLRRuntimeHost, IID_ICLRRuntimeHost, (LPVOID*)&runtimeHost) == S_OK)

if (runtimeHost->Start() == S_OK)

{

DWORD pReturnValue;

runtimeHost->ExecuteInDefaultAppDomain(L"C:\\[login to view URL]", L"[login to view URL]", L"EntryPoint", L"asd", &pReturnValue);

runtimeInfo->Release();

metaHost->Release();

runtimeHost->Release();

}

return 0;

}

BOOL APIENTRY DllMain(HMODULE hModule,

DWORD ul_reason_for_call,

LPVOID lpReserved

)

{

switch (ul_reason_for_call)

{

case DLL_PROCESS_ATTACH:

CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)ControlThread, hModule, NULL, NULL);

break;

case DLL_THREAD_ATTACH:

case DLL_THREAD_DETACH:

case DLL_PROCESS_DETACH:

break;

}

return TRUE;

}

///////////////////////////////////////////////////////////////////////////////////////////////////////

And now here is the source code for the C# [login to view URL]

///////////////////////////////////////////////////////////////////////////////////////////////////////

namespace ExampleProject

{

public class Example

{

public static int EntryPoint(string pwzArgument)

{

string processName = [login to view URL]().ProcessName;

[login to view URL]("The current process is " + processName);

return 0;

}

}

}

///////////////////////////////////////////////////////////////////////////////////////////////////////

What I want is to create a second thread in the C++ project and call it TickEvent

///////////////////////////////////////////////////////////////////////////////////////////////////////

DWORD WINAPI TickEvent(LPVOID lpParam)

{

while (true)

{

Sleep(500);

//[login to view URL]();

}

}

///////////////////////////////////////////////////////////////////////////////////////////////////////

And use it like this in the C# [login to view URL]

///////////////////////////////////////////////////////////////////////////////////////////////////////

namespace ExampleProject

{

public class Example

{

public static int EntryPoint(string pwzArgument)

{

[login to view URL] += OnTick;

}

private static void OnTick(EventArgs args)

{

string processName = [login to view URL]().ProcessName;

[login to view URL]("Called every 500ms inside " + processName);

return 0;

}

}

}

///////////////////////////////////////////////////////////////////////////////////////////////////////

The question from me is, can you make an event like this, which is controlled from the C++ dll and usable from any C# dll?

If you can complete this task, I will be asking from you to also implement different C++ API which are usable in C# inside the events earlier created.

Please take a moment and use the passw0rd "I am C# pr0grammer" to confirm you have read my post in general and are sure you can complete it.

C#-programmering C++-programmering C-programmering Programvaruarkitektur .NET

Projekt-id: #22266905

About the project

13 offerter Distansprojekt Aktivt 4 år sedan

13 frilansare har lagt bud på i genomsnitt $509 för det här jobbet

AwaisChaudhry

Hi,. I have gone through the brief details mentioned on the job. I have done multiple jobs with .NET, C Programming, C# Programming, C++ Programming, Software Architecture which are the skills required to get this job Mer

$750 USD inom 7 dagar
(91 omdömen)
8.3
adampohp79

I can start work right now and I can show you perfect result in a short time. Please contact me freely. Waiting for you with your great news.

$500 USD inom 7 dagar
(43 omdömen)
6.0
mackthehobbit

"I am C# pr0grammer" - I understand your frustration with automated bids. Hello, I'm very experienced with C, C++ and C# programming and I believe I can help you implement this project. I would implement this type of f Mer

$400 USD inom 5 dagar
(19 omdömen)
4.3
umairkaramat24

Hello There. How are you doing?. I have read the description, I have great experience doing similar jobs related to these skills .NET, C Programming, C# Programming, C++ Programming, Software Architecture. Please start Mer

$555 USD inom 9 dagar
(8 omdömen)
3.6
sirajahmadzai

Dear Hiring Manager, After reviewing your job description, it’s clear that you’re looking for a candidate that is extremely familiar with the responsibilities associated with the role, and can perform them confidentl Mer

$533 USD inom 7 dagar
(9 omdömen)
3.8
greenguru2018

Hello, How are you? My pleasure to bid your project. I've read carefully your project description. I have more than five years experience in development related with your project. Your satisfaction with the project is Mer

$500 USD inom 7 dagar
(10 omdömen)
3.7
KonstanBer

Good day! I'm a licensed full stack developer and designer. I have rich experiences in python/Django, python selenium , image processing by using openCV and google apis and extensions. I have many experiences in c#, Mer

$500 USD inom 7 dagar
(4 omdömen)
3.2
Artemrodin1987

I am C# pr0grammer I am C# pr0grammer I am C# pr0grammer I am C# pr0grammer I am C# pr0grammer I am C# pr0grammer I am C# pr0grammer

$400 USD inom 7 dagar
(6 omdömen)
3.2
wolfman199311

Dear Client. Thanks for your job posting. My slogan is to satisfy the client's requirement with a low price. However, high quality and fast-deliver is promised. I am interested in your project. Because I have strong sk Mer

$500 USD inom 7 dagar
(2 omdömen)
2.4
kyj629

Hi! Nice to meet you. My name is Nemanja, c/c# expert from Russia. I have read your project detail carefully. I have about 10 years of experience. I can complete your job within a few days. please contact me so that w Mer

$500 USD inom 7 dagar
(3 omdömen)
1.8
FrostyTheSnowMan

Hi, I'm a c# developer. I think I can handle it.

$555 USD inom 10 dagar
(0 omdömen)
0.0