Re: how can i create an simple event under c#

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Paul G. Tobey [eMVP] (ptobey_no_spam_at_instrument_no_spam.com)
Date: 06/08/04


Date: Tue, 8 Jun 2004 08:56:39 -0700

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=en&lr=lang_en&ie=UTF-8&oe=UTF-8&group=microsoft.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.

"Elmar Jacobs" <elmar.jacobs@target-instruments.com> wrote in message
news:OGLfqfWTEHA.1544@TK2MSFTNGP09.phx.gbl...
> 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
>
>



Relevant Pages

  • Re: unmanaged events
    ... minimum you have to P/Invoke CreateEvent and P/Invoke ... WaitForSingleObject on the returned handle. ... In your C# app, create a delegate and an event. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Reading Serial Port
    ... > SetEvent(ShutdownEvent); ... > WaitForSingleObject(ShutdownEvent, INFINITE); ... The WaitForSingleObject in Stop accomplishes nothing and should be removed. ... Maybe I need another Event that tells me when the reader thread is ...
    (microsoft.public.vc.mfc)
  • WaitForSingleObject
    ... WaitCommEvent in Listener thread, I set the com mask SetCommMask API ... But when I read all contents from the file with ReadFile API, ... WaitForSingleObject is not wait second times in listener loop. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Reading Serial Port
    ... always getting a "huge" memory leak of about 200bytes every time I ... SetEvent(ShutdownEvent); ... WaitForSingleObject(ShutdownEvent, INFINITE); ... The WaitForSingleObject in Stop accomplishes nothing and should be removed. ...
    (microsoft.public.vc.mfc)
  • Re: TStringList OnChange and Threads
    ... You could create an event (Win API "CreateEvent") and set it as ... 'Flagged' when there is something in the queue. ... safe the time for counting TStringlist, but I have plenty of time...;-) ...
    (borland.public.delphi.non-technical)