Raising Events

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Um9i?=

    #1

    Raising Events

    I'm new to event processing in vs 2005 - what I'm trying to achieve is
    broadly a network simulation of two workstations sending packets to each
    other .

    I have defined a class 'Workstation' and I was hoping to define events where
    in instance A (or workstation) I could raise an event 'Send' (which takes in
    the destination instance B (or workstation) and the Packet to send). The
    event would then trigger a 'Receive' event in instance B to receive the
    packet.

    Public Class Workstation

    Public Event SendPacket(ByVa l Destination As Workstation, ByVal
    SentPacket As Packet)
    Public Event ReceivePacket(B yVal Source As Workstation, ByVal
    ReceivePacket As Packet)

    Public Sub Send(ByVal Destination As Workstation, ByVal SentPacket As
    Packet) Handles Me.SendPacket
    ' send packet to Destination
    End Sub

    Public Sub Receive(ByVal Source As Workstation, ByVal SentPacket As
    Packet) Handles Me.ReceivePacke t
    ' process packet (pick packet to return)
    ' send packet to Source
    End Sub

    What I would like to do is raise the ReceivePacket event in the Destination
    Workstation but the editor is not letting me add a statement along the lines
    of RaiseEvent Destination.Rec eivePacket()

    any help in this area of two instances 'sending messages' between them would
    be much appreciated.

    TIA
    Rob
  • Spam Catcher

    #2
    Re: Raising Events

    =?Utf-8?B?Um9i?= <Rob@discussion s.microsoft.com wrote in
    news:CC1D10BF-B599-4303-8470-66380396A235@mi crosoft.com:
    What I would like to do is raise the ReceivePacket event in the
    Destination Workstation but the editor is not letting me add a
    statement along the lines of RaiseEvent Destination.Rec eivePacket()
    >
    any help in this area of two instances 'sending messages' between them
    would be much appreciated.
    You're raising a SendPacket event right?

    Thus on the other end, it's still a SendPacket event - not a ReceivePacket
    event.

    To make the event name make sense on both sends, perhaps choose a generic
    event name such as "PacketData " or "ProcessPacket" .

    Comment

    • Rob

      #3
      Re: Raising Events

      Thanks for your reply - I was thinking more along the lines of

      Instance A is my 'client' an instance of my Workstation class
      Instance B is my 'target' an instance of my Workstation class

      1) Instance A Raises a Send Event (passing in Instance B as the
      destination and a 'packet' to send as parameters)
      2) The Send event raises a Receive Event for Instance B (passing in
      'Me' as the Source workstation and the 'packet')
      3) The Receive event in Instance B 'receives' the Instance A
      workstation and the packet (as a parameter), processes the packet and
      determines the response packet
      4) Instance B Raises a Send Event (passing in Instance A as the
      destination and a packet to send)

      Action 1 and 4 are of course the same.

      Is it a case of passing in the 'address' of the Instance B receive
      event into the Instance A send event in action 1 - so action 2 can
      raise that event?

      tia



      On Sat, 31 Mar 2007 09:49:50 GMT, Spam Catcher
      <spamhoneypot@r ogers.comwrote:
      >=?Utf-8?B?Um9i?= <Rob@discussion s.microsoft.com wrote in
      >news:CC1D10B F-B599-4303-8470-66380396A235@mi crosoft.com:
      >
      >What I would like to do is raise the ReceivePacket event in the
      >Destination Workstation but the editor is not letting me add a
      >statement along the lines of RaiseEvent Destination.Rec eivePacket()
      >>
      >any help in this area of two instances 'sending messages' between them
      >would be much appreciated.
      >
      >You're raising a SendPacket event right?
      >
      >Thus on the other end, it's still a SendPacket event - not a ReceivePacket
      >event.
      >
      >To make the event name make sense on both sends, perhaps choose a generic
      >event name such as "PacketData " or "ProcessPacket" .

      Comment

      Working...