Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. IT & Infrastructure
  4. Event and delegate from C# to VB.NET

Event and delegate from C# to VB.NET

Scheduled Pinned Locked Moved IT & Infrastructure
csharphelpquestion
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sri_0099
    wrote on last edited by
    #1

    Hi, i have below short code in C# public delegate void MsgEventHandler(object sender, ChatEventArgs e); public static event MsgEventHandler ChatEvent; private void Message(ChatEventArgs e) { MsgEventHandler temp = ChatEvent; if (temp != null) { foreach (MsgEventHandler handler in temp.GetInvocationList()) { handler.BeginInvoke(this, e, new AsyncCallback(EndAsync), null); } } } and when we translate in vb.NET Public Delegate Sub MsgEventHandler(ByVal sender As Object, ByVal e As ChatEventArgs) Public Shared Event ChatEvent As MsgEventHandler Private Sub EmergencyMessage(ByVal e As ChatEventArgs) Dim temp As MsgEventHandler = ChatEvent If temp <> Nothing Then For Each handler As MsgEventHandler In temp.GetInvocationList() handler.BeginInvoke(Me, e, New AsyncCallback(AddressOf EndAsync), Nothing) Next End If End Sub but i have error, Saying ChatEvent is an event and can not be called directly.Use a 'Raise Event' statement to raise an event. can u help me to figure it out from c# to vb.net? thank you regards Sri

    L 1 Reply Last reply
    0
    • S sri_0099

      Hi, i have below short code in C# public delegate void MsgEventHandler(object sender, ChatEventArgs e); public static event MsgEventHandler ChatEvent; private void Message(ChatEventArgs e) { MsgEventHandler temp = ChatEvent; if (temp != null) { foreach (MsgEventHandler handler in temp.GetInvocationList()) { handler.BeginInvoke(this, e, new AsyncCallback(EndAsync), null); } } } and when we translate in vb.NET Public Delegate Sub MsgEventHandler(ByVal sender As Object, ByVal e As ChatEventArgs) Public Shared Event ChatEvent As MsgEventHandler Private Sub EmergencyMessage(ByVal e As ChatEventArgs) Dim temp As MsgEventHandler = ChatEvent If temp <> Nothing Then For Each handler As MsgEventHandler In temp.GetInvocationList() handler.BeginInvoke(Me, e, New AsyncCallback(AddressOf EndAsync), Nothing) Next End If End Sub but i have error, Saying ChatEvent is an event and can not be called directly.Use a 'Raise Event' statement to raise an event. can u help me to figure it out from c# to vb.net? thank you regards Sri

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Please don't post to multiple forums. This question has already been answered elsewhere.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups