Re: sending events asynchronously



"Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx> wrote in message
news:op.tp4eiwyj8jd0ej@xxxxxxxxxxxxxxxxxxxxxxx
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.

ah yes ive just read it.

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.

yes I gues they are trying to hide the old unsafe windows type event.

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.

aha, I have used AutoResetEvent as well to pass com data onto the data
proceesing thread.
but the point is I dont want to stop the UI thread by waiting for the com
event
wich I assume will have to happen unless I have missed something
and the com thread certainly doesnt want to wait for anything other than
data from the com port,
and im trying to avoid the UI polling to see if there is data to be written
to the UI.

The only exeption is when the program ends, it has to wait for the handle to
close before it can abort the thread,
and I have put that in OnClosed but the main window is still visible wich is
undesirable but I couldnt find a better place, it wouldnt let me add a
Dispose();

Is there a thread synchronization object wich will create an 'event' in the
UI task like having a callback
but always in the UI thread context ? can the 'WindowProc' be utilised in c#
?

The only alternative so far seems yet another thread.

It seems like microsoft dont want you to write multithreaded UI apps,
as a result ive come accros a few apps so far wich so obviously do
everything in the UI thread.
even the debugger is inefective when the program is stoped not in the UI
thread.

thanks
Colin =^.^=


.



Relevant Pages

  • Re: sending events asynchronously
    ... To my mind multi threading should be made as easy as adding a control, ... wich took a little while to grasp becuase its not so clear. ... problems to the unwary due to mfc window control classes in particular ... for as long as threads have been in Windows anyway). ...
    (microsoft.public.dotnet.languages.csharp)
  • capturing CmdKey input to floating windows from within the main form.
    ... wich I must say seems realy good. ... reflection and picking items in the chain of windows and parent windows ... I cant very easily make all my window classes inherit a custom class ... wich then inherits Control, as im using this windows from this library ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Authentification from a SAM base
    ... ComputerScience students on wich they upload their files and other things. ... authentification base SAM of a WindowsServer2003. ... Windows WMI and ADSI. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • sony network walkman(usb problem)
    ... I have an NW-MS7 sony digital music player, wich is only compatible ... It uses flash memoy cards(sony memory sticks) wich are ... the driver only works with windows, but OS X won't let the virtual pc ...
    (microsoft.public.mac.virtualpc)
  • Re: Applying restrictions to xp services
    ... > Does anybody know how I can prevent user's from stopping a windows XP ... > I've got an java application wich I have configured as a windows xp ... > standalone XP instalation, wich only have local accounts (e.g., ... If your application is running as a correctly installed service, ...
    (microsoft.public.windowsxp.security_admin)

Loading