none
Not able to access event RRS feed

  • Question

  • I have C# class library as
    
    
    
    public delegate void OnFileRecycled(object sender, string filePath);
    
     
    
    public interface IDataRecycle
    
    {
    
    event OnFileRecycled FileRecycled;
    
    }
    
     
    
     
    
    /// <summary>
    
    /// This Class manages all recycling related activity
    
    /// </summary>
    
    public class DataRecycler : IDataRecycle
    
    {
    
    //event raised when file is deleted
    
    public event OnFileRecycled FileRecycled;
    
    }
    
    Now i am creating the object of DataRecycler in VB.net but not able get the FileRecycled
    
    

     

    Friday, May 14, 2010 9:52 AM

Answers

  • Can you post the VB.NET code as well? What is the compiler error?
    Thanks Naveen http://naveensrinivasan.com
    • Marked as answer by SamAgain Wednesday, May 26, 2010 9:57 AM
    Friday, May 14, 2010 3:30 PM
  • Hi,

       Since there's no VB.NET code of your implementation. I could only give you the following sample code based on your C# code snippets.

    Imports System
    
    Namespace EventAccessability
      Class Program
        Private Shared Sub Main(ByVal args As String())
          Dim obj As New DataRecycler()
          AddHandler obj.FileRecycled, AddressOf obj_FileRecycled
          obj.[RaiseEvent](Nothing, "dummy path")
        End Sub
        
        Private Shared Sub obj_FileRecycled(ByVal sender As Object, ByVal filePath As String)
          Console.WriteLine("File recycled!")
        End Sub
      End Class
      
      
      Public Delegate Sub OnFileRecycled(ByVal sender As Object, ByVal filePath As String)
      Public Interface IDataRecycle
        Event FileRecycled As OnFileRecycled
      End Interface
      
      Public Class DataRecycler
        Implements IDataRecycle
        'event raised when file is deleted
        Public Event FileRecycled As OnFileRecycled
        Public Sub [RaiseEvent](ByVal sender As Object, ByVal filePath As String)
          FileRecycled(sender, filePath)
        End Sub
      End Class
      
    End Namespace

    Please mark the right answer at right time.
    Thanks,
    Sam
    • Marked as answer by SamAgain Wednesday, May 26, 2010 9:57 AM
    Wednesday, May 26, 2010 9:57 AM

All replies

  • Can you post the VB.NET code as well? What is the compiler error?
    Thanks Naveen http://naveensrinivasan.com
    • Marked as answer by SamAgain Wednesday, May 26, 2010 9:57 AM
    Friday, May 14, 2010 3:30 PM
  • Hi,

       Since there's no VB.NET code of your implementation. I could only give you the following sample code based on your C# code snippets.

    Imports System
    
    Namespace EventAccessability
      Class Program
        Private Shared Sub Main(ByVal args As String())
          Dim obj As New DataRecycler()
          AddHandler obj.FileRecycled, AddressOf obj_FileRecycled
          obj.[RaiseEvent](Nothing, "dummy path")
        End Sub
        
        Private Shared Sub obj_FileRecycled(ByVal sender As Object, ByVal filePath As String)
          Console.WriteLine("File recycled!")
        End Sub
      End Class
      
      
      Public Delegate Sub OnFileRecycled(ByVal sender As Object, ByVal filePath As String)
      Public Interface IDataRecycle
        Event FileRecycled As OnFileRecycled
      End Interface
      
      Public Class DataRecycler
        Implements IDataRecycle
        'event raised when file is deleted
        Public Event FileRecycled As OnFileRecycled
        Public Sub [RaiseEvent](ByVal sender As Object, ByVal filePath As String)
          FileRecycled(sender, filePath)
        End Sub
      End Class
      
    End Namespace

    Please mark the right answer at right time.
    Thanks,
    Sam
    • Marked as answer by SamAgain Wednesday, May 26, 2010 9:57 AM
    Wednesday, May 26, 2010 9:57 AM