Re: sending events asynchronously



On Sun, 01 Apr 2007 12:12:17 -0700, colin <colin.rowe1@xxxxxxxxxxxxxxxxxx> wrote:

[...]
idealy I just want to send an event to the main message pump of the UI
thread wich is how it would be done in the lower level languages

I have tried the OnEvent method but this still just runs the event handler in the current thread.

Is there some equavalent in c# or something that I have overlooked ?

I just posted an answer to a similar question in a different thread.

Basically, .NET uses the term "event" to describe something that is very different from what people used to programming Windows know as an "event", but the old Win32 "event" still exists. See, for example, the AutoResetEvent class.

IMHO, it was a mistake for the term "event" to be used given that it conflicts with the pre-existing notion of event handles in Win32, because it quite often leads to people thinking that the delegate/event handler paradigm in .NET is somehow equivalent when in fact it has nothing to do with Win32 event handles.

You can do all of the same event-driven producer/consumer stuff in .NET that you can do in Win32. You need not use the delegate/event handler stuff, and in fact there's probably no good reason to. Instead you use waitable event objects, where AutoResetEvent and ManualResetEvent are the two most likely classes to be useful for your purposes.

Pete
.


Loading