Click here to Skip to main content
15,917,702 members
Home / Discussions / C#
   

C#

 
AnswerRe: Compare 2 Datatables Pin
André Kraak10-Oct-11 8:27
André Kraak10-Oct-11 8:27 
GeneralRe: Compare 2 Datatables Pin
jojoba2010-Oct-11 8:30
jojoba2010-Oct-11 8:30 
GeneralRe: Compare 2 Datatables Pin
André Kraak10-Oct-11 9:30
André Kraak10-Oct-11 9:30 
QuestionFire a C# Event/Delegate in C++, or: EventHandling via DLL Pin
Tonkpils10-Oct-11 4:27
Tonkpils10-Oct-11 4:27 
AnswerRe: Fire a C# Event/Delegate in C++, or: EventHandling via DLL Pin
DaveyM6910-Oct-11 7:09
professionalDaveyM6910-Oct-11 7:09 
GeneralRe: Fire a C# Event/Delegate in C++, or: EventHandling via DLL Pin
Tonkpils13-Oct-11 4:37
Tonkpils13-Oct-11 4:37 
AnswerRe: Fire a C# Event/Delegate in C++, or: EventHandling via DLL Pin
TheGreatAndPowerfulOz10-Oct-11 12:13
TheGreatAndPowerfulOz10-Oct-11 12:13 
GeneralRe: Fire a C# Event/Delegate in C++, or: EventHandling via DLL Pin
Tonkpils11-Oct-11 1:01
Tonkpils11-Oct-11 1:01 
Thanks for the both answers!

@Dave
Your proposal and your code syntax ist just right! Compiles without any error and it hits my problem.
But in jumps never into OnYourDelegate after calling SetEvent(..) in the DLL.

@Ahmed
Is works fine, but if I did correctly understand, there's has to be a thread permenently running in the background to check up the call of the event!? When the event in the DLL raises, my own event 'theEventTriggered' is called from the thread.
It works fine, but I want to raise the Event in the C# code like an interrupt out of the DLL. Without permanently checking in a own thread. You see a possibility there?


I thought, I can give the DLL the adress of my C# event oder delegate. So, when the event in the DLL is fired, my event in C# is also fired. Like in the following way:
C#
/*** C# code ***/
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Auto)]
public static extern IntPtr CreateEvent
(
	IntPtr lpEventAttributes,
	bool bManualReset,
	bool bIntialState,
	string lpName
);

public delegate void DoHandler();

public void Foo()
{
  //Get an adress
  IntPtr EventsAdress = CreateEvent(IntPtr.Zero, false, false, "TheEvent");

  //Register Delegate with this Adress (PseudoCode)
  DoHandler doH = new DoHandler(MethodForEventAction);
  doH = (DoHandler)Marshal.GetDelegateForFunctionPointer(EventsAdress, typeof(DoHandler));
  // -> causes PROBLEM in Visual Studio: Invalid Pointer!

  //Give the adress to the C++ code
  SetClientParam(wParam, EventsAdress );
}

public void MethodForEventAction()
{
  Console.WriteLine("Event from DLL raised.");
}

C++
/*** C++ code ***/
SetEvent(EventsAdress); //-> Console: "Event from DLL raised."


Thanks for your input! Your suggestions are very useful. Do you got any idea about my second post?
GeneralRe: Fire a C# Event/Delegate in C++, or: EventHandling via DLL Pin
TheGreatAndPowerfulOz14-Oct-11 4:51
TheGreatAndPowerfulOz14-Oct-11 4:51 
GeneralRe: Fire a C# Event/Delegate in C++, or: EventHandling via DLL Pin
Tonkpils18-Oct-11 0:17
Tonkpils18-Oct-11 0:17 
GeneralRe: Fire a C# Event/Delegate in C++, or: EventHandling via DLL Pin
TheGreatAndPowerfulOz18-Oct-11 8:23
TheGreatAndPowerfulOz18-Oct-11 8:23 
QuestionHow to highlight all occurrences of a word in a Word document?? Pin
fiaolle10-Oct-11 4:20
fiaolle10-Oct-11 4:20 
AnswerRe: How to highlight all occurrences of a word in a Word document?? Pin
Pete O'Hanlon10-Oct-11 4:52
mvePete O'Hanlon10-Oct-11 4:52 
GeneralRe: How to highlight all occurrences of a word in a Word document?? Pin
fiaolle10-Oct-11 5:08
fiaolle10-Oct-11 5:08 
GeneralRe: How to highlight all occurrences of a word in a Word document?? Pin
Pete O'Hanlon10-Oct-11 5:19
mvePete O'Hanlon10-Oct-11 5:19 
GeneralRe: How to highlight all occurrences of a word in a Word document?? Pin
fiaolle10-Oct-11 6:25
fiaolle10-Oct-11 6:25 
GeneralRe: How to highlight all occurrences of a word in a Word document?? Pin
Shameel11-Oct-11 0:32
professionalShameel11-Oct-11 0:32 
AnswerRe: How to highlight all occurrences of a word in a Word document?? Pin
jschell10-Oct-11 8:08
jschell10-Oct-11 8:08 
GeneralRe: How to highlight all occurrences of a word in a Word document?? Pin
fiaolle10-Oct-11 9:07
fiaolle10-Oct-11 9:07 
QuestionIs there a way to run nunit Test class 50 times in a loop ? Pin
Subin Mavunkal10-Oct-11 0:59
Subin Mavunkal10-Oct-11 0:59 
AnswerRe: Is there a way to run nunit Test class 50 times in a loop ? Pin
Pete O'Hanlon10-Oct-11 1:14
mvePete O'Hanlon10-Oct-11 1:14 
GeneralRe: Is there a way to run nunit Test class 50 times in a loop ? Pin
Subin Mavunkal10-Oct-11 1:24
Subin Mavunkal10-Oct-11 1:24 
GeneralRe: Is there a way to run nunit Test class 50 times in a loop ? Pin
Pete O'Hanlon10-Oct-11 1:25
mvePete O'Hanlon10-Oct-11 1:25 
GeneralRe: Is there a way to run nunit Test class 50 times in a loop ? Pin
Subin Mavunkal10-Oct-11 2:47
Subin Mavunkal10-Oct-11 2:47 
GeneralRe: Is there a way to run nunit Test class 50 times in a loop ? Pin
Pete O'Hanlon10-Oct-11 3:07
mvePete O'Hanlon10-Oct-11 3:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.