how can i create an simple event under c#

  • Thread starter Thread starter Elmar Jacobs
  • Start date Start date
E

Elmar Jacobs

hi folk,

i have 2 threads an i want to create an event, so that thread1 can inform
thread2 about an update.
in c++ i would make it over

HANDLE hEvent = INVALID_HANDLE_VALUE;
in thread1
{...
SetEvent(hEvent);
.....
}

and in thread2
DWORD WINAPI Thread1(PVOID pArg)
{
.... WaitForSingleObject(hEvent, INFINITE);

......
}


but under c# i have no idea how i can realise it. If it is possible that the
event can carry an data byte, it was perfect.
Can anybody help me?

thanks a lot,
elmar
 
Well, you could P/Invoke directly to those API calls. I'm sure that the
method signatures for WaitForSingleObject and CreateEvent have been posted.
As I recall, SetEvent isn't actually an API call, but maps to ModifyEvent
with suitable arguments.

You can search the archived posts here:

http://groups.google.com/groups?hl=...soft.public.dotnet.framework.compactframework

Further, the OpenNETCF SDF has the declaration for WaitForSingleObject in
process.cs. CreateEvent is declared in core.cs. SetEvent/ResetEvent have
also been defined in core.cs to handle setting or clearing the event state
for you.

Events don't carry data. Maybe you should tell us what you're really trying
to do. There might be a significantly better way...

Paul T.
 
Back
Top