Click here to Skip to main content
16,013,642 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to Change the default location of file --- VB.NET Pin
mominafiz7-Jun-10 0:16
mominafiz7-Jun-10 0:16 
GeneralRe: How to Change the default location of file --- VB.NET Pin
Johnny J.7-Jun-10 0:20
professionalJohnny J.7-Jun-10 0:20 
Questionbit shift problem Pin
tuolesi6-Jun-10 3:36
tuolesi6-Jun-10 3:36 
AnswerRe: bit shift problem Pin
Luc Pattyn6-Jun-10 4:02
sitebuilderLuc Pattyn6-Jun-10 4:02 
GeneralRe: bit shift problem Pin
tuolesi6-Jun-10 4:25
tuolesi6-Jun-10 4:25 
GeneralRe: bit shift problem Pin
Luc Pattyn6-Jun-10 4:33
sitebuilderLuc Pattyn6-Jun-10 4:33 
AnswerRe: bit shift problem Pin
Dave Doknjas6-Jun-10 11:19
Dave Doknjas6-Jun-10 11:19 
QuestionConfusion around events in my plugin framework Pin
Sonhospa6-Jun-10 2:04
Sonhospa6-Jun-10 2:04 
Hello everybody,

in my application (.NET 2.0) I use plugins for different tasks and want to pass events between the plugins as well as with the MDI window. The basic idea of the following code setup works: after starting the app, the handler is added and the event is raised through the interface and the plugins 'Process()' routine, resulting in the trace-line which has been defined in the main app's corresponding Sub (pluginInfo_ButtonClicked).

The funny thing is that, when raised with exactly the same command in the button.click event of the plugin, the event isn't heard from the main app anymore - no trace-line written. Confused | :confused: The event handler should still be there, at least I didn't purposely remove it.

I don't yet fully understand everything around events, so I might just miss something out. Could anyone please have a look and tell me where I'm going wrong?

Thank you
Michael

' ... the Interface
Public Interface IPluginInfo
    Event MyButtonClicked As EventHandler
    Sub Process()
    ReadOnly Property Name() As String
End Interface

' ... the MDI Application
Public Class MainAppPluginhandler
    Private pluginInfo As IPluginInfo

    Public Sub New()

        (...creating an instance of IPluginInfo here)

        Try
            AddHandler pluginInfo.MyButtonClicked, AddressOf pluginInfo_ButtonClicked

            Trace.WriteLine(String.Format("+ Handler for PlugIn {0} installed in MDIForm.", pluginInfo.Name))
            pluginInfo.Process()
        Catch ex As Exception
        End Try
    End Sub

    Private Shared Sub pluginInfo_ButtonClicked(ByVal sender As Object, ByVal e As EventArgs)
        Trace.WriteLine("+ Event 'ButtonClicked' received by PlugInHandler!")
    End Sub

End Class

' ... and the plugin class
Public Class MyPlugin
    Implements IPluginInfo

    Public Event MyButtonClicked(ByVal sender As Object, ByVal e As System.EventArgs) Implements IPluginInfo.MyButtonClicked
    
    Private Sub OnMyButtonClicked(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyButton.Click
        RaiseEvent MyButtonClicked(Me, Me, EventArgs.Empty)
        Trace.WriteLine("+ Event MyButtonClicked raised.")
    End Sub

    Public Sub Process() Implements IPluginInfo.Process
        Trace.WriteLine("+ Function 'Process' started in MyPlugin... wait 2 seconds.")
        Thread.Sleep(2000)
        Trace.WriteLine("+ Event MyButtonClicked' raised in MyPlugin.")
        RaiseEvent MyButtonClicked(Me, EventArgs.Empty)
    End Sub
End Class

QuestionHow to match between two images? Pin
phowarso5-Jun-10 16:07
phowarso5-Jun-10 16:07 
AnswerRe: How to match between two images? Pin
Dr.Walt Fair, PE5-Jun-10 16:59
professionalDr.Walt Fair, PE5-Jun-10 16:59 
AnswerRe: How to match between two images? Pin
Anshul R8-Jun-10 20:02
Anshul R8-Jun-10 20:02 
AnswerRe: How to match between two images? Pin
mvdcorput11-Jun-10 22:57
mvdcorput11-Jun-10 22:57 
QuestionDRAWIMAGE to Print Image Pin
Anubhava Dimri5-Jun-10 2:08
Anubhava Dimri5-Jun-10 2:08 
AnswerRe: DRAWIMAGE to Print Image Pin
Luc Pattyn5-Jun-10 2:55
sitebuilderLuc Pattyn5-Jun-10 2:55 
GeneralRe: DRAWIMAGE to Print Image Pin
Anubhava Dimri6-Jun-10 18:45
Anubhava Dimri6-Jun-10 18:45 
GeneralRe: DRAWIMAGE to Print Image Pin
Luc Pattyn7-Jun-10 1:13
sitebuilderLuc Pattyn7-Jun-10 1:13 
QuestionGUID changes from immediate window to table? [modified] Pin
lemarshall4-Jun-10 17:08
lemarshall4-Jun-10 17:08 
AnswerRe: GUID changes from immediate window to table? Pin
Dave Kreskowiak4-Jun-10 19:21
mveDave Kreskowiak4-Jun-10 19:21 
AnswerRe: GUID changes from immediate window to table? Pin
riced4-Jun-10 20:10
riced4-Jun-10 20:10 
QuestionApache configuration files parser Pin
Murr@y4-Jun-10 7:54
Murr@y4-Jun-10 7:54 
AnswerRe: Apache configuration files parser Pin
Dave Kreskowiak4-Jun-10 8:53
mveDave Kreskowiak4-Jun-10 8:53 
GeneralRe: Apache configuration files parser Pin
Murr@y4-Jun-10 18:38
Murr@y4-Jun-10 18:38 
GeneralRe: Apache configuration files parser Pin
Dave Kreskowiak4-Jun-10 19:16
mveDave Kreskowiak4-Jun-10 19:16 
QuestionVB.Net syntax. Pin
priyamtheone4-Jun-10 6:27
priyamtheone4-Jun-10 6:27 
AnswerRe: VB.Net syntax. Pin
Smithers-Jones4-Jun-10 7:42
Smithers-Jones4-Jun-10 7:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.