Does VB.Net's lack of implicit interfaces make what I'm trying to do impossible?

后端 未结 1 748
北海茫月
北海茫月 2020-12-22 02:47

I know VB.Net does not allow implicit interface implementation like C#. And thus code like the following has no direct VB.Net correlation:

public interface I         


        
相关标签:
1条回答
  • 2020-12-22 03:33

    I think, as with the subs you've already shown, you need to pass all of your calls down to the same calls in the base class. The trickiest are the event handlers, but DoWork can be implemented as:

    Public Shadows Custom Event DoWork As DoWorkEventHandler Implements IBackgroundWorkerAdapter.DoWork
        AddHandler(Value As DoWorkEventHandler)
            AddHandler MyBase.DoWork, Value
        End AddHandler
        RemoveHandler(Value As DoWorkEventHandler)
            RemoveHandler MyBase.DoWork, Value
        End RemoveHandler
        RaiseEvent(sender As Object, e As DoWorkEventArgs)
            MyBase.OnDoWork(e)
        End RaiseEvent
    End Event
    

    And similarly for the other event handlers. In this way, event handlers added through your DoWork event are actually added to your base classes DoWork event.

    0 讨论(0)
提交回复
热议问题