Re: Event enqueing in PostMessage style
From: John Lafrowda (laa.laa_at_laa.com)
Date: 03/31/04
- Next message: Brian Newtz: "Re: Event enqueing in PostMessage style"
- Previous message: phoenix: "Re: RegExp different behavior in .NET and VB script?"
- In reply to: Brian Newtz: "Re: Event enqueing in PostMessage style"
- Next in thread: Brian Newtz: "Re: Event enqueing in PostMessage style"
- Reply: Brian Newtz: "Re: Event enqueing in PostMessage style"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 1 Apr 2004 00:18:48 +0200
Dear Brian,
the actual problem is a bit more complicated than the given example. So the
constraint is really to finalise the calling method before entering the
event handler - just like WinAPI coders [like me] would do it by
PostMessage.
Maybe the answer is less obvious than I thought...
Thanks,
John
"Brian Newtz" <anonymous@discussions.microsoft.com> schrieb im Newsbeitrag
news:OBHj#s2FEHA.3568@tk2msftngp13.phx.gbl...
> Wouldn't the obvious answer be to raise the event at the end of the
method?
>
> -Brian
>
>
> "John Lafrowda" <laa.laa@laa.com> wrote in message
> news:c4f5kj$9pt$1@news.uni-stuttgart.de...
> > Dear all,
> >
> > I'm currently having some trouble with the event mechanisms in the .net
> > framework. What I am looking for is a way to schedule events like it is
> done
> > with PostMessage in the WinAPI: When I raise an event, the raising code
> > should be continued. The scheduled event should just be called after
> > execution of the current function has terminated. In WinAPI programming,
> > this could be done by posting a message through PostMessage which would
be
> > invoked not earlier as the calling thread returns to the central message
> > loop.
> > The .net framework, however, handles events more in a "SendMessage"
style,
> > meaning that the event handler is called immediately and interrupts the
> > calling code.
> >
> > Cosider the following simple example in VB.net (the mechanism would be
> > slightly different in C# as the RaiseEvent statement is missing here -
the
> > effect is nevertheless the same with C# techniques):
> >
> > Provide a form class (Form1) with a single button (Button1) on it:
> > ==================================================================
> > Public Class Form1
> > Inherits System.Windows.Forms.Form
> >
> > [#Region " Windows Form Designer generated code "]
> >
> > Private WithEvents MyEventObj As New MyEventClass
> >
> > Private Sub MyHandler() Handles MyEventObj.MyEvent
> > MsgBox("During Event")
> > End Sub
> >
> > Private Sub Button1_Click(ByVal sender As System.Object, _
> > ByVal e As System.EventArgs) Handles
> > Button1.Click
> > MsgBox("Before Call")
> > MyEventObj.RaiseIt()
> > MsgBox("After Call")
> > End Sub
> > End Class
> >
> > ==================================================================
> >
> > In addition, the MyEventClass is needed with following contents:
> > ==================================================================
> > Public Class MyEventClass
> >
> > Public Event MyEvent()
> >
> > Public Sub RaiseIt()
> > RaiseEvent MyEvent()
> > End Sub
> > End Class
> >
> > ==================================================================
> >
> > Now, the message boxes are appearing in the sequence "Before Call" ->
> > "During Event" -> "After Call", where I would like to see the sequence
> > "Before Call" -> "After Call" -> "During Event".
> > Probably the .net event model is the wrong way to go, but I don't see
any
> > other at the moment except for going back to the WinAPI with
PostMessage,
> > which does not provide the features of managed code (and object/contents
> > transmission) and is thus not exactly what I want, either.
> >
> > Maybe I don't see the obvious here... Any solutions?
> >
> > Best regards,
> >
> > John
> >
> >
>
>
- Next message: Brian Newtz: "Re: Event enqueing in PostMessage style"
- Previous message: phoenix: "Re: RegExp different behavior in .NET and VB script?"
- In reply to: Brian Newtz: "Re: Event enqueing in PostMessage style"
- Next in thread: Brian Newtz: "Re: Event enqueing in PostMessage style"
- Reply: Brian Newtz: "Re: Event enqueing in PostMessage style"
- Messages sorted by: [ date ] [ thread ]